在PHP中检查大量代理

I'm working on a proxy scraper, which will search for proxies on the internet, then will check all of them, then store them in a file.

I have around 20k proxies I need to check, but it is too slow the script I have now and it issues a Cloudflare timeout error.

Here's my code right now, but the problem is, it takes aaages and always gives me a timeout error.

// this is looped in a foreach
$proxy = "127.0.0.1";
list($host,$port) = explode(':', $proxy);

if($fp = @fsockopen($host,$port,$errCode,$errStr,5)){   
    return $proxy;
}
fclose($fp);

I hope someone can provide a solution. Thank you!