note 34283 deleted from function.gethostbyaddr by irchtml
| From: | irchtml@php.net | Date: | Sun, 29 Feb 2004 21:28:47 +0000 |
| Subject: | note 34283 deleted from function.gethostbyaddr by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66005@lists.php.net to get a copy of this message | ||
Note Submitter: Matt AKA junkie
----
I was trying to find a simple way to take the ISP out of the client address and got it working.
<?
$client = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$str = preg_split("/\./", $client);
$i = count($str);
$x = $i - 1;
$n = $i - 2;
$isp = $str[$n] . "." . $str[$x];
# And whenever you want to echo the isp, just:
echo $isp;
?>
Of course, using this, you could create a function where you just enter the IP address in and get
the ISP, but that's simple enough for you.