Converting JSON string to Associative array in PHP
What I'm trying to Do is so simple yet everything I tries had failed. I
have the following string: "{"msg":"background1.jpg"}", and I want to
convert it to an array to access the msg value. this should simply be done
like so(or so I've thought):
$theString = "{"msg":"background1.jpg"}";
var_dump(json_decode($theString, TRUE));
The vr_dump() is dumping NULL, also tried:
var_dump(json_decode(json_encode($theString), TRUE));
This dumps string(45) "{"msg":"background1.jpg"}"
and tried many many more things, but all failed. Any thought please.
No comments:
Post a Comment