Write your results to a file and create a mail from the file once a day and send it to yourself with cron, or use a database to hold the results if one is available.
Instead of making a mail message with your loop, write information back to the file. Format your file like this: url, pass, fail, last_fail_time <? $url_file = "url.txt"; $url_list = file($url_file); //loop through each line foreach($url_list as $line) { $part = expode(",",$line); $url = $part[0]; if(isset($part[1])) { $pass = $part[1]; } else { $pass = 0; } if(isset($part[2])) { $fail = $part[2]; } else { $fail = 0; } if(isset($part[3])) { $last_fail = $part[3]; } else { $last_fail = "None"; } $fp = fsockopen ($url_list[$x], 80, $errno, $errstr, 30); if($fp) { $pass++; } else { $fail++; $last_fail = date("r"); } $status[] = "$url, $pass, $fail, $last_fail"; } $new_file = implode("\n",$status); $fp = fopen($file,"w"); fputs($fp,$new_file); fclose($fp); ?> The create another PHP script that simply loads up the .txt file and formats an email with it to give you the results, and call it with cron/at. I wrote that kind of quickly, so adapt to your needs and it may have errors...but hopefully you get the idea. You can take out the isset() parts if you want to go through and format your file in the correct format (with all four columns). if you leave them in there, it'll basically take the file you have now and reformat it to the new one the first time it's ran. Also it'll make it so you can just add in a url, w/o having to put zero, zero, and None for the other columns. adapt to your needs. ---John Holmes... ----- Original Message ----- From: "Dan McCullough" <[EMAIL PROTECTED]> To: "PHP General List" <[EMAIL PROTECTED]> Sent: Thursday, May 23, 2002 1:03 PM Subject: [PHP] Array question - Please help > 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("[EMAIL PROTECTED]", $subject, $message, "From: [EMAIL PROTECTED]\r\n" > ."Reply-To: [EMAIL PROTECTED]\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 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php