Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2013
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. if(!function_exists('apache_request_headers'))
  4. {
  5.     function apache_request_headers()
  6.     {
  7.         static $arh = array();
  8.  
  9.         if (!$arh)
  10.         {
  11.             $rx_http = '/\AHTTP_/';
  12.             foreach ($_SERVER as $key => $val)
  13.             {
  14.                 if(preg_match($rx_http, $key))
  15.                 {
  16.                     $arh_key = preg_replace($rx_http, '', $key);
  17.                     $rx_matches = array();
  18.  
  19.                     // do some nasty string manipulations to restore the original letter case
  20.                     // this should work in most cases
  21.                     $rx_matches = explode('_', $arh_key);
  22.                     if( count($rx_matches) > 0 and strlen($arh_key) > 2 )
  23.                     {
  24.                         foreach($rx_matches as $ak_key => $ak_val)
  25.                         {
  26.                             $rx_matches[$ak_key] = ucfirst($ak_val);
  27.                         }
  28.  
  29.                         $arh_key = implode('-', $rx_matches);
  30.                     }
  31.  
  32.                     $arh[$arh_key] = $val;
  33.                 }
  34.             }
  35.         }
  36.  
  37.         return $arh;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement