title: PHP Get HTTP Response Code
body: <p>I have found a way to get the HTTP response code from a URL using <code>get_headers($url)</code>. This function returns an array like the following...</p>
  
  <pre><code>Array
  (
      [0] =&gt; HTTP/1.1 200 OK
      [1] =&gt; Date: Sat, 29 May 2004 12:28:13 GMT
      [2] =&gt; Server: Apache/1.3.27 (Unix)  (Red-Hat/Linux)
      [3] =&gt; Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
      [4] =&gt; ETag: "3f80f-1b6-3e1cb03b"
      [5] =&gt; Accept-Ranges: bytes
      [6] =&gt; Content-Length: 438
      [7] =&gt; Connection: close
      [8] =&gt; Content-Type: text/html
  )
  </code></pre>
  
  <p>My problem is that I may have a large list of URLs that I want to loop though and get the HTTP response code for each URL. It seems like a nasty and slow way to use this function inside a loop for potentially 100's of URLs.</p>
  
  <p>How can I speed up this process and make it cleaner or is this the best way to do it? I would love to know your suggestions.</p>
  
  <p>Thanks</p>