Examples of parse_str functions that can automatically split query characters in PHP
This article mainly introduces PHP can automatically split the query character Parse_str function Use example, the small part has not seen a function, this split URL in the query string is convenient, the need for friends can refer to the next
Directly on the code:
The code is as follows:
$str = "1&errid=1&fee=2&balance=2582&fails=&msgid=634541149212681528&msg= all sent successfully. ";
Parse_str ($str, $output);
echo $output [' MsgId ']; Output 634541149212681528
Definition and usage
The Parse_str () function parses the query string into a variable.
Grammar
Parse_str (String,array)
Parameter description
string is required. Specifies the string to parse.
Array is optional. Specifies the array name for the stored variable. This parameter indicates that the variable is stored in the array.
Hints and Notes
Note: If the array parameter is not set, the variable set by the function overrides the variable with the same name.
Note: The MAGIC_QUOTES_GPC setting in php.ini affects the output of the function. If enabled, the variable is converted by addslashes () before Parse_str () is resolved.
Example
Example 1
The code is as follows:
Parse_str ("Id=23&name=john%20adams");
echo $id. "
";
Echo $name;
?>
Output:
The code is as follows:
23
John Adams
Example 2
The code is as follows:
Parse_str ("Id=23&name=john%20adams", $myArray);
Print_r ($myArray);
?>
Output:
Copy the code code as follows:
Array
(
[id] = 23
[Name] = John Adams
)
http://www.bkjia.com/PHPjc/852813.html www.bkjia.com true http://www.bkjia.com/PHPjc/852813.html techarticle examples of parse_str functions that can automatically split query characters in PHP this article mainly introduces the use of the PARSE_STR function that can automatically divide the query characters in PHP, the small part has not seen ...