-2
People below I have a code that checks the ping on MS of a url or IP but what I need is to take the value of the average of the result that is within the array [10]
Example :
M dia = 74ms
I just wanted the value 74 in a echo
.
Below is a test code
<?php
function pingAddress($ip) {
$pingresult = exec("ping -n 3 $ip", $outcome, $status);
if (0 == $status) {
$status = "alive => ( ".print_r($outcome[10])." )";
} else {
$status = "fora";
}
}
pingAddress("www.google.com");
?>
$outcome[10]
is an array or is an array value?– Sam
@sam he is taking the value of the 11th position of the executed variable in
exec()
– Erlon Charles
Ask the question the result of
print_r(pingAddress("www.google.com"));
– Costamilam