Biranchi Biranchi - 6 months ago 47
PHP Question

Getting location details from IP in PHP

Is it possible to get the location details from the users IP Address in PHP.

Any suggestions ??

Thanks

Answer
$ip = '98.229.152.237';
$xml = simplexml_load_file("http://ipinfodb.com/ip_query.php?ip=$ip");
print_r($xml);

Output:

SimpleXMLElement Object
(
    [Ip] => 98.229.152.237
    [Status] => OK
    [CountryCode] => US
    [CountryName] => United States
    [RegionCode] => 33
    [RegionName] => New Hampshire
    [City] => Manchester
    [ZipPostalCode] => 03103
    [Latitude] => 42.9403
    [Longitude] => -71.4435
    [Timezone] => -5
    [Gmtoffset] => -5
    [Dstoffset] => -4
)