- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
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=xyz@gmail.com &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] => xyz@gmail.com [country] => India )