PHP parse_str() Function


The parse_str() function is a in-built function in PHP which parses a query string into variables.

Syntax
parse_str(string,array)
Parameters
  • string - (Required) Specify the string to pharse.
  • array - (Optional) Specify the name of the array to store the variables.
Example
<?php
parse_str("name=Ram & age=16 & std=10TH");
  echo $name."<br>";
  echo $age."<br>";
  echo $std;
?> 

Output

Ram
16
10TH
Example
<?php  
parse_str("name=Ram & age=36",$yourArray);  
print_r($yourArray);  
?> 

Output

Array ( [name] => Ram [age] => 36 )

Prev Next