What is the usage of the php parse_str function?
The parse_str function in PHP is used to parse a query string and store it in variables. Its basic syntax is as follows:
parse_str(string $str, array &$arr)
$str is the string to be parsed, and $arr is an optional parameter used to store the parsed results.
For example, if there is a query string “foo=bar&baz=qux”, by using the parse_str function, the results can be stored in an array.
$query_string = "foo=bar&baz=qux";
parse_str($query_string, $result);
print_r($result);
The output result is:
Array
(
[foo] => bar
[baz] => qux
)
In this way, it is convenient to store the parameters from the query string into an array for processing and manipulation in the program.