Find a geolocation of an IP address including latitude, longitude, city, region and country. Compare the data from multiple IP location providers.

This is also part of the Awesome Functions js library

PHP Code


 $ip = $_SERVER['REMOTE_ADDR']; 

 $content = file_get_contents("".$ip);

 $json = json_decode($content, true);

 //Output all the data results


 //Output only few results

 $lon = $json['lon'];

 $lat = $json['lat'];

 $city = $json['city'];

 $state = $json['state'];


Jquery Code

 <script type="application/javascript" src="jquery.min.js"></script>
 <script type="application/javascript">
   $.getJSON("", function(data, status)
     var d1 = JSON.stringify(data, null,2)

Result - JSON