Expand|Select|Wrap|Line Numbers
- <?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
Expand|Select|Wrap|Line Numbers
- 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