parse_str

PHP 4, PHP 5, PHP 7, PHP 8
parse_str - Parses the string into variables

parse_str( string$string, arrayresult ): void

Parses 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).

Parameters

string

The input string.

result

If the second parameter result is present, variables are stored in this variable as array elements instead.

Warning:

Using this function without the result parameter is highly DISCOURAGED and DEPRECATED as of PHP 7.2.

Return Values

No value is returned.

Notes

Note:

All variables created (or values returned into array if second parameter is set) are already urldecoded.

Note:

To get the current QUERY_STRING, you may use the variable $_SERVER['QUERY_STRING']. Also, you may want to read the section on variables from external sources.

Changelog

Version Description
8.0.0 result is no longer optional.
7.2.0 Usage of parse_str without a second parameter now emits an E_DEPRECATED notice.

Related Functions

Example of parse_str

Show all examples for parse_str

PHP Version:


Function parse_str:

Strings Functions

Most used PHP functions