what is the syntax of the PARSE_STR() function in php?
parse_str(string,array)
Parameter | Description |
---|---|
string | Required. Specifies the string to parse |
array | Optional (Required from PHP 7.2). Specifies the name of an array to store the variables. This parameter indicates that the variables will be stored in an array. |
examples of the PARSE_STR() function
Examples 1. In this example, we parse a query string into variables.
<?php
parse_str("name=Peter&age=43");
echo $name."<br>";
echo $age;
?>
Example 2. Store the variables in an array:
<?php
parse_str("name=Peter&age=43",$myArray);
print_r($myArray);
?>