Page 3 of 3

Re: How do you check if a variable has numeric content?

Posted: Tue Mar 07, 2017 6:40 am
by Amit Tiwari
function ping($host, $count = 3, $port = 60, $timeout = 8) {
$ping_times = [];

for ($i = 0; $i < $count; $i++) {
$start_time = microtime(true);
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);

if (!$fp) {
echo "sorry this is not right";
}

$end_time = microtime(true);
fclose($fp);
$response_time = round((($end_time - $start_time) * 1000), 0);
$ping_times[] = $response_time;
}

return $ping_times;
}

if (isset($domain))
{
$ping = ping("www.otssolutions.com", 80, 10);
$average = array_sum($ping_times) / count($pings);
}


echo "$average";