Latest news
Home » Tag Archives: geolocation api

Tag Archives: geolocation api

Find Country Name By IP Address using PHP

Use the following Code to get geo location details based on Your IP $country data=getLocationInfoByIp(); echo $country data['country']; echo $country data['city']; function getLocationInfoByIp() { $current_ip = @$_SERVER['HTTP_CLIENT_IP']; $forwardip = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remoteip = @$_SERVER['REMOTE_ADDR']; $geo_data = array('country'=>'', 'city'=>''); if(filter_var($current_ip, FILTER_VALIDATE_IP)) { $ipaddress = $current_ip; } elseif(filter_var($forwardip, FILTER_VALIDATE_IP)) { $ipaddress = $forwardip; } else { $ipaddress = $remoteip; } $your_ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ipaddress)); // print_r($your_ip_data); ...

Read More »