Issue
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$isptc = gethostbyaddr($ip);
$ispoh = preg_split("/./", $isptc);
$xy = count($ispoh);
$x = $xy - 1;
$y = $xy - 2;
$i = $xy - 3;
$ispp = $ispoh[$i];
$isp = $ispoh[$y] . "." . $ispoh[$x];
echo"<b>ip: $ip</b><br>";
echo"<b>isp: $ispp$isp</b>";
?>
In this above mentioned codings, i didn’t get the output from $ispp and $isp.
Solution
I Got an answers from the following PHP Codings….
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$url=file_get_contents("http://whatismyipaddress.com/ip/$ip");
preg_match_all('/<th>(.*?)<\/th><td>(.*?)<\/td>/s',$url,$output,PREG_SET_ORDER);
$isp=$output[1][2];
$city=$output[9][2];
$state=$output[8][2];
$zipcode=$output[12][2];
$country=$output[7][2];
?>
<body>
<table align="center">
<tr><td>ISP :</td><td><?php echo $isp;?></td></tr>
<tr><td>City :</td><td><?php echo $city;?></td></tr>
<tr><td>State :</td><td><?php echo $state;?></td></tr>
<tr><td>Zipcode :</td><td><?php echo $zipcode;?></td></tr>
<tr><td>Country :</td><td><?php echo $country;?></td></tr>
</table>
</body>
Answered By – Rajesh
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0