Created
June 14, 2016 18:02
-
-
Save ivanrosolen/52cbf13f9b579a38a88ccdfc7e6908ac to your computer and use it in GitHub Desktop.
apache_request_headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( !function_exists('apache_request_headers') ) { | |
function apache_request_headers() { | |
$arh = array(); | |
$rx_http = '/\AHTTP_/'; | |
foreach($_SERVER as $key => $val) { | |
if( preg_match($rx_http, $key) ) { | |
$arh_key = preg_replace($rx_http, '', $key); | |
$rx_matches = array(); | |
// do some nasty string manipulations to restore the original letter case | |
// this should work in most cases | |
$rx_matches = explode('_', $arh_key); | |
if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) { | |
foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val); | |
$arh_key = implode('-', $rx_matches); | |
} | |
$arh[ucfirst(strtolower($arh_key))] = $val; | |
} | |
} | |
return( $arh ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment