note 44013 deleted from function.gethostbyaddr by tomsommer

From: Date: Mon, 12 Jul 2004 16:19:39 +0000
Subject: note 44013 deleted from function.gethostbyaddr by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73105@lists.php.net to get a copy of this message
Note Submitter: eternal@1337.li ---- By getting the name for the ip, the name includes the suffix (ie pc1.home.lan). But I wanted to use only the name, here's my script (very simple) - i'm too lazy to build a function: $ip = "192.168.0.1"; $dns = gethost($ip); $pos = strpos($dns, "."); $name = substr($dns, 0, $pos); echo $name; /*gethostbyaddr() tends to lag on various systems if your server is on a *nix system, this is faster*/ function gethost ($ip) { $host = host $ip; return (($host ? end ( explode (' ', $host)) : $ip)); }

« previous php.notes (#73105) next »