Current Location: Home> Function Categories> parse_str

parse_str

Parse strings into multiple variables
Name:parse_str
Category:String
Programming Language:php
One-line Description:Parses the query string into the variable.

Definition and usage

parse_str() function parse the query string into a variable.

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

Note: The magic_quotes_gpc setting in the php.ini file affects the output of the function. If enabled, the variable will be converted by addslashes() before parse_str() is parsed.

Example

Example 1

Parses query strings into variables:

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

Try it yourself

Example 2

Store variables in an array:

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

Try it yourself

grammar

 parse_str ( <
i > string , array )
parameter describe
string Required. Specifies the string to be parsed.
array Optional. Specifies the name of the array that stores the variables. This parameter indicates that the variable will be stored in the array.
Similar Functions
Popular Articles