title: Improve This 404 Checker PHP Script?
body: <p>It's main purpose is to check URLS. You have to create a 404.txt and sites.txt, put the URLS you want in sites.txt and run the script below called grab.php, any urls which are 404 in sites.txt will go in 404.txt. Remember this has to be in same folder, 404.txt,sites.txt and grab.php.  </p>
  
  <p>You see this PHP script doesn't work all the time, it cannot handle thousands of URLS. It sometimes works with hundreds or less, could you help improve this?</p>
  
  <pre><code> &lt;?php
  error_reporting(0);
  $error_404 = "Not Found";
  $list_404 = array();
  $sites = file('sites.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  
  foreach($sites as $site)
  {
          $response = get_headers($site);
          if (strpos($response[0], $error_404))
          {
                  $list_404[]=$site."
  ";
          }
  }
  
  file_put_contents('404.txt',$list_404);
  ?&gt;
  </code></pre>