PHP parse_str () function example tutorial
Definition and usage
This parse_str () function parses a variable from the query string.
Syntax
Parse_str (string, array)
| Parameter | Description |
|---|
| String | Required |
| Array | Optional. The specified name stores the variable of the array. This parameter indicates that the variable is stored in an array. Note: this parameter is used in PHP 4.0.3. |
Tips and instructions
Note: If the array parameter is not set, this function will overwrite the same name of the existing variable.
Note: magic_quotes_gpc setting affects the output function in the php. Ini file. If enabled, parse_str () is parsed before variable conversion and addslashes ().
--------------------------------------------------------------------------------
Example 1
<? Phpparse_str ("id = 23 & name = Kai % 20Jim"); echo $ id. "<br/>"; echo $ name;?>Result.
23Kai Jim
Instance 2.
<? Phpparse_str ("id = 23 & name = Kai % 20Jim", $ myArray); print_r ($ myArray);?>
Result.
Array ([id] => 23 [name] => Kai Jim) |