Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
[ Posted by Long + ] json test json decode function
$json = '{"a": {"b":"5"}}';
$valueDecodeObject = json_decode($json);
$valueDecodeArray = json_decode($json, true);
echo "<p>Option 1: </p>";
// echo $valueDecodeObject['a']['b']; => error
echo $valueDecodeObject->a->b;
echo "<p>Option 2: </p>";
echo $valueDecodeArray['a']['b'];
// echo $valueDecodeArray->a->b; => error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment