Created
May 31, 2013 14:29
-
-
Save jlittlejohn/5685363 to your computer and use it in GitHub Desktop.
PHP: JSON Decode
This file contains hidden or 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
<?php | |
/* Set Content Encoding Header */ | |
$json = '[{"type":"cat","name":"Alfie","age":2},{"type":"dog","name":"Bella","age":6}]'; | |
/* Parse JSON to Object */ | |
$object = json_decode($json); | |
/* Parse JSON to Array */ | |
$array = json_decode($json,true); | |
/* Print Object */ | |
var_dump($object); | |
/* Print Array */ | |
var_dump($array); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment