How can I turn a string below into an array?
JavaScript
x
pg_id=2&parent_id=2&document&video
This is the array I am looking for,
JavaScript
array(
'pg_id' => 2,
'parent_id' => 2,
'document' => ,
'video' =>
)
Advertisement
Answer
You want the parse_str
function, and you need to set the second parameter to have the data put in an array instead of into individual variables.
JavaScript
$get_string = "pg_id=2&parent_id=2&document&video";
parse_str($get_string, $get_array);
print_r($get_array);