$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";