[thelist] json_decode

Bob Meetin bobm at dottedi.biz
Fri Jun 21 14:08:44 CDT 2013


This seems simple enough, but it's not working. I have a json string to decode:

<?php
$json = {"admin_style":"","admin_language":"","language":"","editor":"jce","helpsite":"","timezone":"America\/Juneau"}; // this is pulled out of a mysql table
$obj = json_decode($json, true);
$result = $obj['0']->timezone; // This should pull the timezone value, yes?

echo "Result: $result<br />";
?>

Of course no result, so I tried quoting the sting with single ticks.

<?php
$json = {"admin_style":"","admin_language":"","language":"","editor":"jce","helpsite":"","timezone":"America\/Juneau"};
$json = "'$json'";
$obj = json_decode($json, true);
$result = $obj['0']->timezone;

echo "Result: $result<br />";
?>

Also tried: $result = $obj[0]->timezone; // without ticks

Still no result. What am I missing?
Bob





More information about the thelist mailing list