English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP parse_str() Function Usage and Example

PHP String Function Manual

The parse_str() function is used to parse strings into multiple variables.

Syntax

void parse_str ( string $str[, array &$arr ] )

Definition and Usage

It is used to parse a string into variables, if str is the query string passed in by URL, then it parses it into variables and sets it to the current scope (if arr is provided, it will be set to the array).

Return Value

No value returned

Parameter

Serial NumberParameters and Description
1

str

Input String

2

array

If the second variable arr is set, the array will store the elements in the form of array elements as a substitute.

Online Example

Try the following example to parse the query string into variables:

<?php
   //parse_str() parses the query string into variables
   parse_str("name=Gopal K Verma&age=45");
   
   echo $name."<br>";
   echo $age;
?>
Test and see‹/›

Output Result

Gopal K Verma
45

PHP String Function Manual