<<< Previous question <<< Question ID#0625.md >>> Next question >>>
What is the best approach for converting this string:
$string = "a=10&b[]=20&c=30&d=40+50";
// Into this array?
array(- [ ] {
["a"]=>
string(- [ ] "10"
["b"]=>
array(- [ ] {
[0]=>
string(- [ ] "20"
}
["c"]=>
string(- [ ] "30"
["d"]=>
string(- [ ] "40 50"
}
- A) Use the parse_str() function to translate it to an array()
- B) Write a parser completely by hand, it's the only way to make sure it's 100% accurate
- C) Pass the variable to another PHP script via an HTTP GET request and return the array as a serialized variable
- D) Just call unserialize() to translate it to an array()
Answer
Answer: A