Skip to content

Instantly share code, notes, and snippets.

@edavis25
Last active November 4, 2016 00:47
Show Gist options
  • Save edavis25/986d88f195f6348b6f9e82cd7d6c3491 to your computer and use it in GitHub Desktop.
Save edavis25/986d88f195f6348b6f9e82cd7d6c3491 to your computer and use it in GitHub Desktop.
Parse JSON string as PHP array.
<?php
/*
* Create a simple javascript array and call the JSON "stringify" method upon it.
* Pass the stringified array variable via the URL & GET method and use this line to turn it into a standard PHP array.
*/
$array = json_decode(str_replace('\\', '', $_REQUEST['URL-PARAM-NAME']));
// URL-PARAM-NAME = whatever name the JSON string was given when passed via URL (keep single quotes)
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment