parse_str
Parse strings into multiple variables
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.
Parses query strings into variables:
<?php parse_str ( "name=Bill&age=60" ) ; echo $name . "<br>" ; echo $age ; ?>
Try it yourself
Store variables in an array:
<?php parse_str ( "name=Bill&age=60" , $myArray ) ; print_r ( $myArray ) ; ?>
Try it yourself
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. |