The mb_parse_str() function in PHP is used to parse the GET, POST, and COOKIE data and it sets the global variable. It parses the URL encoded data and detects the encoding. After that, it converts the coding in the internal encoding and sets values for the global variables. This function is supported in PHP 7 or higher versions.
Syntax
string mb_parse_str($str_string, $array_result)
Parameters
mb_parse_str() accepts the following two parameters −
$str_string − This parameter is used for the URL encoded data.
$result − The result parameter will be an array holding the decrypted and character encrypted converted values.
Return Values
The mb_parse_str() function returns True on success or it returns False on failure. If it parses the data successfully, then it will return True, else it will return False.
Example 1
<?php $str_string ="user_id= 123 &[email protected] &country=India"; $array_result; // parse the data mb_parse_str($str_string, $array_result); print_r($array_result); ?>
Output
It will produce the following output −
Array ( [user_id] => 123 [email] => [email protected] [country] => India )