note 34283 added to function.gethostbyaddr
| From: | Matt at rack1 dot php dot net | Date: | Mon, 21 Jul 2003 04:37:19 +0000 |
| Subject: | note 34283 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52442@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyaddr.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34283
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34283&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34283&report=yes