function ping($host, $port, $timeout) { $tB = microtime(true); $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); if (!$fP) { return "N/A"; } $tA = microtime(true); return round((($tA - $tB) * 1000), 0); } //Print ping("www.google.com", 80, 5);