Possible Duplicate:
Parse query string into an array
What's the fastest method, to parse a string of URL parameters into an array of accessible variables?
$current_param = 'name=Peter&car=Volvo&pizza=Diavola&....';
// Results in a nice array that I can pass:
$result = array (
'name' => 'Peter',
'car' => 'Volvo',
'pizza' => 'Diavola'
)
I've tested a regular expression, but this takes way too long. My script needs to parse about 10000+ URLs at once sometimes :-(
KISS - keep it simple, stupid
Submitting form values through GET method A web form when the method is set to GET method, it submits the values through URL.
Definition and Usage. The parse_str() function parses a query string into variables. Note: If the array parameter is not set, variables set by this function will overwrite existing variables of the same name.
Use parse_str()
.
$current_param = "name=Peter&car=Volvo&pizza=Diavola";
parse_str($current_param, $result);
print_r($result);
The above will output
Array
(
[name] => Peter
[car] => Volvo
[pizza] => Diavola
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With