I have a foreach loop that looks at an associative array and for every server in the array, it pings the server and looks at the results. It works with no errors, but it seems that the exec() keeps pinging the same IP over and over. Any idea why?
Here's the code:
<center><table bgcolor=EEEEEE width=19% border=0><tr><td><center><font size=-1 face=arial>Server Status</td></tr></table><table bgcolor=EEEEEE width=19% border=0>
<?php
$results = array (
'blah' => 0,
'home' => 0,
'oyoy' => 0,
'test' => 0,
'eek' => 0,
'blah2' => 0,
'yahoo.com' => 0,
'mugs' => 0
);
foreach ($results as $server => $status) {
exec("ping -n 1 -w 1 $server", $output);
list ($read) = split(" ", $output[3]);
if ($read == "Reply") {
$status = 1;
}
if ($status == 1) {
echo "<tr><td><font face=arial color=#007700>$server:</td><td><font size=-2 color=#007700> UP!</td></tr>";
} else {
echo "<tr><td><font face=arial color=#770000>$server:</td><td><font size=-2 color=#770000> DOWN!</td></tr>";
}
}
?>