My problem is that its IP addresses i need to ping.
<?
function ping($host) {
echo 'HOSTNAME: <a class="text" href="http://' . $host . '">' . $host . '</a><br>';
$ip = gethostbyname($host);
echo 'IP: '. $ip . '<hr>';
$result = ping -c 1 $ip;
$a = strpos($result, "time=");
$b = strpos($result, " ms");
if (!$a || !$b) {
return FALSE;
}
$a = $a+5;
$r = substr($result, $a, $b-$a);
return $r;
}
$hostname = 'www.phpbuilder.com';
$ping = ping($hostname);
if(!$ping) echo 'Ping timed out.'; else
echo 'ping time: ' . $ping . ' ms';
I dont have a domain name like above, just an IP address. So when I try it I assume it tries to convert the hostname into an IP and it fails.
Any other ideas?