Skip to content

Instantly share code, notes, and snippets.

@toddsby
Created April 2, 2014 18:08
Show Gist options
  • Select an option

  • Save toddsby/9939708 to your computer and use it in GitHub Desktop.

Select an option

Save toddsby/9939708 to your computer and use it in GitHub Desktop.
JSON to $_POST php
$content_type_args = explode(‘;’, $_SERVER['CONTENT_TYPE']); // parse content_type string
if ($content_type_args[0] == ‘application/json’) {
$_POST = json_decode(file_get_contents(‘php://input’),true); // store decoded json in $_POST object
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment