Is there a PHP function to convert a query string to an array?

Viewed 39953

I'm basically looking for the opposite of http_build_query().

I have the following as a string:

foo=bar&bar[var]=foo

And I want the following (to pass into http_build_query):

array(
    'foo' => 'bar',
    'bar' => array(
         'var' => 'foo',
    )
)
2 Answers

Maybe it will work . parse_str 2nd parameter mandatory as of PHP 7.2+

parse_str(urldecode($builded_content), $output)

print_r($output)
Related