this script gives the result below when ping is good, a numerical value i think in the form of a string
Average = 0ms
0ms
0 is $fianlstr
when ping is bad --- $finalstr is (100% los ------- yes exactly this (100% los
later in the script i have an if elseif statements
but when $finalstrng is (100% los the status still says good
Please help need to get $finalstrng say bad when not a numeric value
Thanks
Code:
<?php
function pinger ($serverIP)
{
$pingReturn = exec ('ping ' .$serverIP );
return $pingReturn ;
}
$tmp1 = explode(',' , pinger("localhost"));
echo "$tmp1[2] \n";
$newstring=substr($tmp1[2],10);
echo "$newstring \n";
$finalstr=substr_replace($newstring ,"",-2);
echo $finalstr;
?>
Average = 0ms
0ms
0 is $fianlstr
when ping is bad --- $finalstr is (100% los ------- yes exactly this (100% los
later in the script i have an if elseif statements
Code:
if ($finalstrng <= 50) {$status = "good";}
elseif ($finalstrng > 50 && $finalstrng <= 100){$status = "congested";}
else {$status = "bad";}
Please help need to get $finalstrng say bad when not a numeric value
Thanks
Comment