The parse_str () function parses the query string to a variable.
Syntax
Parse_str (string, array)
Note: If the array parameter is not set, the variables set by this function will overwrite the variables with the same name.
*/
Parse_str ("id = 23 & name = john % 20 adams ");
Echo $ id. "<br/> ";
Echo $ name;
// 23
// John
$ Str = "first = value & arr [] = foo + bar & arr [] = baz"; // define a string
Parse_str ($ str); // parses the string into a variable.
Echo $ first; // output the value of $ first
Echo "<br> ";
Echo $ arr [0]; // output the value of $ arr [0] foo bar
Echo "<br> ";
Echo $ arr [1]; // Output $ arr [1] value baz
Echo "<br> ";
Parse_str ($ str, $ output); // stores the variable parsed by the string in $ output.
Echo $ output ['first']; // output the value of $ first.
Echo "<br> ";
Echo $ output ['arr'] [0]; // output the value of $ arr [0] foo bar.
Echo "<br> ";
Echo $ output ['arr'] [1]; // outputs the value baz of $ arr [1].
/*
Note: The magic_quotes_gpc setting in php Tutorial. ini affects the output of this function. If enabled, the variable will be converted by addslashes () before parse_str () resolution.