Created
November 21, 2016 08:59
-
-
Save phpfiddle/04994650f4b8d6fb39fcfcaab8a375fb to your computer and use it in GitHub Desktop.
[ Posted by Long + ] json test json decode function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre> | |
<?php | |
$json = '{"a": {"b":"5"}}'; | |
$valueDecodeObject = json_decode($json); | |
$valueDecodeArray = json_decode($json, true); | |
echo "<p>Option 1: </p>"; | |
var_dump($valueDecodeObject); | |
// echo $valueDecodeObject['a']['b']; => error | |
echo $valueDecodeObject->a->b; | |
echo "<p>Option 2: </p>"; | |
var_dump($valueDecodeArray); | |
echo $valueDecodeArray['a']['b']; | |
// echo $valueDecodeArray->a->b; => error | |
?> | |
</pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment