PHP parse_str()Functions

PHP String 参考手册PHP String Reference Manual

Examples

Parse the query string into variables:

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

Run example »

Definition and Usage

The parse_str() function parses a 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, the variables will be converted by addslashes() before being parsed by parse_str().


Syntax

parse_str(string,array)

Parameter Description
string Required. Specifies the string to parse.
array Optional. Specifies the name of the array to store the variables. This parameter indicates that the variables are stored in an array.

Technical Details

Return value: No return value.
PHP Version: 4+
Changelog: In PHP 4.0.3, thearrayparameter was added.


More Examples

Example 1

Store the variables into an array:

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

Run example »


PHP String 参考手册PHP String Reference Manual Other Extensions