title: apache_request_headers and array_key_exists
body: <p>This is more of a warning than of a question, but someone may be able to provide a better solution.</p>
  
  <p>I am sending a custom request header from my Android application.
  When the request arrives on the PHP server, I check for the existence of this header and its values.
  To do this, I get the header array with <strong><code>apache_request_headers()</code></strong> and then do a check for the header with <strong><code>array_key_exists()</code></strong>.</p>
  
  <p>However, <strong><code>array_key_exists('custom-header', $Hdr)</code></strong> will return <strong>false</strong> !
  So I dump the array with print_r and, lo and behold, the array key does exist in the array.
  Here is the output :</p>
  
  <pre><code>Array
  (
      [Accept-Encoding] =&gt; gzip
      [Connection] =&gt; Keep-Alive
      [Content-Type] =&gt; application/x-www-form-urlencoded
      [Content-Length] =&gt; 103
      [Host] =&gt; www.somedomain.com
      [custom-header] =&gt; my-custom-header-value
  )
  </code></pre>
  
  <p>How did I get around this ?</p>
  
  <p>Clone the array like this :</p>
  
  <pre><code>// recuperate the request headers
  $Hdr = apache_request_headers();
  
  // clone the array as it will not correctly search with array_key_exists
  $Keys = array_keys($Hdr);
  $Values = array_values($Hdr);
  $Headers = array();
  for($i = 0; $i &lt; count($Keys); $i++)
  {
      $Headers[$Keys[$i]] = $Values[$i];
  }
  </code></pre>
  
  <p>Now when I query the new array with <strong><code>array_key_exists('custom-header', $Headers)</code></strong>, it returns true !</p>
  
  <p>Is this a known problem ?</p>
  
  <p>Is there a better solution ?</p>
  
  <p><strong>NOTE</strong> : <em>I have changed the names of the real values to protect my code, this is given here as an example - please do not post corrections to these values</em> :-)</p>
  
  <p><strong>EDIT</strong> : This occurs on my shared server running PHP version 5.3.10 on Apache version 2.2.22</p>