Skip to content

Instantly share code, notes, and snippets.

@jlittlejohn
Created May 31, 2013 14:29
Show Gist options
  • Save jlittlejohn/5685363 to your computer and use it in GitHub Desktop.
Save jlittlejohn/5685363 to your computer and use it in GitHub Desktop.
PHP: JSON Decode
<?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