Skip to content

Instantly share code, notes, and snippets.

@choult
Created July 15, 2014 14:23
Show Gist options
  • Save choult/d9d23ed75d1a4997a5ff to your computer and use it in GitHub Desktop.
Save choult/d9d23ed75d1a4997a5ff to your computer and use it in GitHub Desktop.
function respond(array $data = null, $code, $message, array $headers = array()) {
header('HTTP/1.1 ' . $code . ' ' . $message);
header('Content-type: application/json');
foreach ($headers as $k => $v) {
header("$k: $v");
}
print json_encode($data, JSON_NUMERIC_CHECK);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment