Latest web development tutorials

PHP parse_str () function

PHP String Reference PHP String Reference

Examples

To resolve the query string variable:

<?php
parse_str("name=Peter&age=43");
echo $name."<br>";
echo $age;
?>

Running instance »

Definition and Usage

parse_str () function to parse the query string variable.

NOTE: If thearray parameter is not set, the variable is set by the function of the same name will overwrite the existing variable.

Note: php.ini file magic_quotes_gpc setting affects the output of the function.If enabled, then before parse_str () parse the variable is addslashes () conversion.


grammar

parse_str( string,array )

参数 描述
string 必需。规定要解析的字符串。
array 可选。规定存储变量的数组名称。该参数指示变量存储到数组中。

technical details

return value: No return value.
PHP version: 4+
Update log: In PHP 4.0.3, add the array parameter.


More examples

Example 1

Store variables into an array:

<?php
parse_str("name=Peter&age=43",$myArray);
print_r($myArray);
?>

Running instance »


PHP String Reference PHP String Reference