问题
I've a string like this:
$mystring = '{"1":"4","2":"2","3":"3"}';
I need to explode to something like this:
array(
"1" => "4",
"2" => "2",
"3" => "3"
)
I use php 5.4.
回答1:
Just use json_decode.
$dd = json_decode($mystring, true);
var_export($dd);
回答2:
you "string" is very like json so maybe try json_decode()
回答3:
you should use the json decode function, your string looks like json. The second argument tells to make it as an array, not an object.
json_decode($mystring, true);
来源:https://stackoverflow.com/questions/27381807/explode-string-into-array-with-key-and-value