void parse_str(string $queryString [, array &$arr])
(PHP 4, PHP 5)
| $queryString | A querystring which should be parsed into variables. |
|---|---|
| $arr | If provided, key-value pairs will populate this local array instead of using local variables. |
| RETURNS | Nothing, side-effect is that local variables are created for each key-value pair. |
This function parses a string that is in the same format as a URI query string and places the key-value pairs into variables within the local scope.
Given a query string like the one below:
make=datsun&model=510&color=blue
The following variables will be created in the local scope (after calling parse_str):
$make = 'datsun'; $model = '510'; $color = 'blue';
// Parse the supplied query string into the local scope parse_str('make=datsun&model=510&color=blue'); echo 'Make: '.$make.'<br>'; echo 'Model: '.$model.'<br>'; echo 'Color: '.$color.'<br>';