Current Location: Home> Function Categories> mb_parse_str

mb_parse_str

Parse GET/POST/COOKIE data and set global variables
Name:mb_parse_str
Category:Multi-byte string
Programming Language:php
One-line Description:Parses query strings and breaks them into variables

Function name: mb_parse_str()

Function: parse query string and break it into variables

Applicable version: PHP 4 >= 4.0.6, PHP 5, PHP 7

Usage: mb_parse_str(string $encoded_string, array &$result): bool

parameter:

  • $encoded_string: The query string to parse.
  • &$result: The parsed results will be stored in this array.

Return value:

  • Returns true on success, and false on failure.

Example:

 $queryString = "name=John&age=30&city=New York"; // 创建一个空数组来存储解析结果$result = array(); // 解析查询字符串mb_parse_str($queryString, $result); // 打印解析后的结果print_r($result);

Output:

 Array ( [name] => John [age] => 30 [city] => New York )

Explanation: The mb_parse_str() function parses the query string into a variable and stores it in an array. In the example, we pass a query string to the function and then print the parsed result using the print_r() function. As you can see, the result is an associative array, where the key is the parameter name in the query string and the value is the value of the parameter.

Similar Functions
Popular Articles