Definition
The parse_str() function parses a query string into variables.
Syntax
parse_str(string, array)
Parameters
Parameter | Description |
---|---|
string |
Required. Specifies the string to parse. |
array |
Optional (Required from PHP 7.2). Specifies the name of an array to store the variables. This parameter indicates that the variables will be stored in an array. |
Example
<?php
parse_str("country=Germany&capital=Berlin", $query_string);
echo $query_string['country'] . "<br>";
echo $query_string['capital'];