PHP parse_str() Function

The parse_str() function parses a query string into variables.

void parse_str ( string $encoded_string [, array &$result ] )

Parses encoded_string as if it were the query string passed via a URL and sets variables in the current scope (or in the array if result is provided).

Example -

Example #1 Using parse_str()

Because variables in PHP can't have dots and spaces in their names, those are converted to underscores. Same applies to naming of respective key names in case of using this function with result parameter.

Example #2 parse_str() name mangling

ParameterDescription
encoded_stringThe input string.
resultIf the second parameter result is present, variables are stored in this variable as array elements instead.

No value is returned.