The
parse_str() string function in PHP can be used to parse a URL encoded variable string. This function can have one or two parameters fed to it. If using only one parameter(the target string), the variables will be set in the current scope. If using two parameters like we are using in our second example, the variables get parsed into an array.
1 Parameter
<?php
$myString = "var1=Blue&var2=Red";
parse_str($myString);
echo "$var1 and $var2";
?>
Blue and Red
2 Parameters

<?php
$myString = "var1=Blue&var2=Red&var3=Yellow&var4=Black";
parse_str($myString, $urlEncodedParse);
foreach ($urlEncodedParse as $k => $v) {
echo "$k = $v <br />";
}
?>
var1 = Blue
var2 = Red
var3 = Yellow
var4 = Black