Array question - Please help
| From: | Dan McCullough | Date: | Thu, 23 May 2002 17:03:23 +0000 |
| Subject: | Array question - Please help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-98944@lists.php.net to get a copy of this message | ||
Here is the problem. I have over 60 subdomains to check on a regular basis. I wrote a php script
that gets a list from a text file and then checks whether it can open that domain/subdomain. That
works great. My problem is that everything is lumped together, so I have to scan a list of 60
names for the one that fails, I also get 1 email for each time the check fails.
How can I get a list broken up by failed and passed, and only get one email with a list of the
subdomains that failed.
Here is the script as it stands now.
<?php
$url_file = "url.txt";
$url_list = file($url_file);
for($x = 0; $x < count($url_list); $x++)
{
$url_list[$x] = eregi_replace("[\n\r]","",$url_list[$x]);
$fp = fsockopen ($url_list[$x], 80, $errno, $errstr, 30);
if (!$fp) {
echo "<b>$url_list[$x]</b> has an error. $errstr ($errno)<br>\n";
//$subject = "A URL test has failed";
//$message = "$url_list[$x] has an error. $errstr ($errno)\r\n";
/*mail("dmccullough@foo.com", $subject, $message, "From:
sitealert@foo.com\r\n"
."Reply-To: sitealert@foo.com\r\n"
."X-Mailer: PHP/" . phpversion());*/
} else {
echo "<b>$url_list[$x]</b> is up.<br>\n";
}
}
?>
=====
--------------------------------------------------------
"Theres no such thing as a problem unless the servers are on fire!"
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com