Is there an existing function in PHP for creating an associative array from a delimited string? If not, what would be the most effective way to do this? I am watching the new NVP PayPal API, where requests and responses have the following format:
method=blah&name=joe&id=joeuser&age=33&stuff=junk
I can use explode() so that each pair explode() into the value of the array, but it would be even better if I could perform some function like dictionary_explode and specify a key separator and return an associated array, for example
Array { [method] => blah [name] => joe [id] => joeuser [age] => 33 [stuff] => junk
}
My CS friends tell me that this idea exists in other languages ββlike Python, so I wonder if I have found such a thing for PHP. Right now I'm looking at creating array_walk, but I would prefer something more prepared.
source share