Parse the query string into variables:
<?phpparse_str("name=Peter&age=43");echo $name."<br>";echo $age;?>The parse_str() function parses the query string into variables.
Note: If the array parameter is not set, the variables set by this function will overwrite existing variables with the same name.Note: The magic_quotes_gpc setting in the php.ini file affects the output of this function. If enabled, variables are converted by addslashes() before being parsed by parse_str().
parse_str( string,array )
parameter | describe |
---|---|
string | Required. Specifies the string to be parsed. |
array | Optional. Specifies the name of the array to store the variable. This parameter instructs the variable to be stored in an array. |
Return value: | No return value. |
---|---|
PHP version: | 4+ |
Update log: | In PHP 4.0.3, the array parameter was added. |
Store variables in an array:
<?phpparse_str("name=Peter&age=43",$myArray);print_r($myArray);?>