title: Something faster than get_headers()
body: <p>I'm trying to make a PHP script that will check the HTTP status of a website as fast as possible.</p>
  
  <p>I'm currently using get_headers() and running it in a loop of 200 random urls from mysql database.</p>
  
  <p>To check all 200 - it takes an average of 2m 48s.</p>
  
  <p>Is there anything I can do to make it (much) faster?</p>
  
  <p>(I know about fsockopen - It can check port 80 on 200 sites in 20s - but it's not the same as requesting the http status code because the server may responding on the port - but might not be loading websites correctly etc)</p>
  
  <p>Here is the code..</p>
  
  <pre><code>&lt;?php
    function get_httpcode($url) {
      $headers = get_headers($url, 0);
      // Return http status code
      return substr($headers[0], 9, 3);
    }
  
    ###
    ## Grab task and execute it
    ###
  
  
      // Loop through task
      while($data = mysql_fetch_assoc($sql)):
  
        $result = get_httpcode('http://'.$data['url']);   
        echo $data['url'].' = '.$result.'&lt;br/&gt;';
  
      endwhile;
  ?&gt;
  </code></pre>