UK[pɑ:z] US[pɑ:rs]

vt. Grammatically describe or analyze (words, sentences, etc.)

Third person singular: parses Present participle: parsing Past tense : parsed past participle: parsed

php parse_str() function syntax

How to use the parse_str() function?

php The parse_str() function means parsing a string into multiple variables. The syntax is parse_str(string,array). If the array parameter is not set, the variables set by this function will overwrite the existing variables. variable with the same name.

Function: Parse the query string into a variable

Syntax: parse_str(string,array)

Parameters:

ParametersDescription
stringRequired, Specifies the string to be parsed
arrayOptional, specifies the name of the array to store the variable. This parameter indicates that the variable will be stored in the array.

Description: If the array parameter is not set, the variable set by this function will overwrite the existing variable with the same name. 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().

php parse_str() function example

<?php
parse_str("id=23&name=John Adams",$myArray);
print_r($myArray);
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

Array ( [id] => 23 [name] => John Adams )
<?php
parse_str('id=1&name="独孤求败"',$array);
print_r($array);
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Array ( [id] => 1 [name] => "独孤求败" )