Thursday, 5 September 2013

json can't be displayed as php array

json can't be displayed as php array

The examples I checked seems simple but I can't figure it out what I'm
doing wrong. I'm trying to convert and display JSON text as object array
in PHP.
$json = '{"color1":red, "color2":blue, "color3":yellow}';
$arr= json_decode($json, true);
print_r($arr);
It doesn't output anything. but when I print $json, the output is just fine

No comments:

Post a Comment