0

I cannot multithread this PHP script. How would I say get it to 50 threads a second instead of 1?

<?php
ini_set('max_execution_time', 6000);
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);
?>
Dylan
  • 15
  • 4
  • 1
    but in this particular case curl_multi would be a good starting point –  Jul 08 '15 at 00:03
  • This is a dup, but worth a comment, since the answer is more related to what he is looking for and it's a multithreading http-requests: You can't (and don't really need to) make the script multithreaded, however since your need is to multithread http requests you can use the curl-multi options http://php.net/manual/en/function.curl-multi-init.php – Dekel Jul 08 '15 at 00:03
  • How would I do that to the script? – Dylan Jul 08 '15 at 20:50

0 Answers0