Function apache_request_headers on Nginx


Function apache_request_headers supports only on Apache, how to use it on Nginx. Here is the solution:

if (!function_exists('apache_request_headers')) { 
    function apache_request_headers() { 
        $return = array();
        foreach($_SERVER as $key=>$value) { 
            if (substr($key,0,5)=="HTTP_") { 
                $key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5))))); 
                $return[$key]=$value; 
            }else{
                $return[$key]=$value; 
	        }
        } 
        return $return; 
    } 
}

Leave a Reply