Reputation: 105
Below code works to fetch latitude / longitude from IP address but it doesn't provide zip code.
$str_arr_ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $_SERVER['REMOTE_ADDR']));
if(!empty($str_arr_ipdat)) {
$str_latitude = $str_arr_ipdat->geoplugin_latitude;
$str_longitude = $str_arr_ipdat->geoplugin_longitude;
}
So is there any other free / paid service using which I can get zip code from ip address or latitude / longitude? I have referred many similar questions here but they are too old and some of links for services are not working now days.
Also how accurate will be this free / paid service to get zip code from IP address or latitude / longitude?
Please advise, Thank You
Upvotes: 0
Views: 2010
Reputation: 530
Precision of IP-based location is in the several miles range. The most you can get from IP address is the location of ISP providing the service, usually in the form of city/state. Large cities have hundreds of Zip codes in them. If it's a small city, the ISP probably serves several of them.
So the short answer is no, you cannot get Zip code from IP address with any meaningful precision.
Upvotes: 1