Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
getallheaders function in PHP
<?php
if(!function_exists('getallheaders')){
function getallheaders(){
$headers = array();
foreach ($_SERVER as $name => $value){
if(substr($name, 0, 5) == 'HTTP_'){
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
$headers[$name] = $value;
} else if($name == "CONTENT_TYPE") {
$headers["Content-Type"] = $value;
} else if($name == "CONTENT_LENGTH") {
$headers["Content-Length"] = $value;
} else{
$headers[$name]=$value;
}
}
return $headers;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment