Skip to content

Instantly share code, notes, and snippets.

@rrezzik
Created May 18, 2012 14:26
Show Gist options
  • Select an option

  • Save rrezzik/2725529 to your computer and use it in GitHub Desktop.

Select an option

Save rrezzik/2725529 to your computer and use it in GitHub Desktop.
Using json_encode to go from PHP array to JSON
<?php
// Your PHP array
$my_array = array('array' => array('a', 'b', 'c'));
// Use json_encode to produce JSON
$json_string = json_encode($my_array);
// And let's see it!
echo $json_string . "\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment