PHP – Parse the GET, POST, and COOKIE data using mb_parse_str()

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.


string mb_parse_str($str_string, $array_result)


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

   $str_string ="user_id= 123

   // parse the data
   mb_parse_str($str_string, $array_result);


It will produce the following output −

   [user_id] => 123

   [email] =>

   [country] => India

Updated on: 11-Oct-2021


Kickstart Your Career

Get certified by completing the course

Get Started