WordPress format json in postmeta table

Part 1 – To remove the double quotes/extra characters:

Instead of trying regular expressions, since the output is somewhat predictable, I would try the following instead of the getCapitalLetters function:

function strip_cruft( $str ) {
    $str = str_replace( '";s', '', $str );
    $str = str_replace( '"', '', $str );
    return $str;

Part 2 – To output a populated dropdown:

Use the above function and remember to add a value in between the opening and closing tags:

<?php foreach($posttype as $post) {
    $post = strip_cruft( $post ); ?>
    <option value="<?php echo esc_attr( $post ); ?>">
        <?php echo esc_html( $post ); ?>
<?php } ?>

If you’d like them to be all lowercase, you can use WordPress’s sanitize_title function.