在PHP中检查多个URL的标头响应

I am trying to check the header response of multiple URLs at the same time without having a complicated php block.

<?php
$url = array("http://www.simplysup.co.uk/download/dl/trjsetup692.exe"); 
$headers = get_headers($url);
$response = substr($headers[0], 9, 3);
if ($response != "404") {
echo "PASS";
} else {
echo "FAIL";
}
?>

The above code checks for a single URL at a time. How to perform the same for multiple URLs at the same time? I will also need to trigger an email with the URL when the Header response is 404. Any help would be much appreciated.

I think this could solve your problem.

$fail = false;
$urls = array("http://www.simplysup.co.uk/download/dl/trjsetup692.exe");
foreach ($urls as $url) {
    $headers = get_headers($url);
    $response = substr($headers[0], 9, 3);

    if ($response === "404") {
        $fail = true;
    }
}

if ($fail) {
    echo "FAIL";
} else {
    echo "PASS";
}