Skip to content
Advertisement

PHP: How to extract() values from an associative array with hyphens/dashes in their keys?

I’m referring to this question. Is it possible to extract() values from an associative array with hyphens/dashes in their keys by now?

It’s about an older version of the WordPress Shortcode API. Example:

function bartag_func( $atts ) {
    extract( shortcode_atts( array(
        'foo-bar' => 'something'
    ), $atts ) );

    return "foo = ${foo-bar}";
}
add_shortcode( 'bartag', 'bartag_func' );

Advertisement

Answer

It is still not possible. However, for the PHP.net engine, I have an RFC under discussion that would make it possible in PHP 8.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement