简体   繁体   中英

Php : How to get localities based on ip address

I want to get localities based on IP address in Php. I'm using geoplugin for based on IP, I got cities by using this

$ip_address = $_SERVER['REMOTE_ADDR'];
/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net /php.gp?ip='.$ip_address;
$addrDetailsArr =     unserialize(file_get_contents($geopluginURL)); 
/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city']; 

/*Get Country name by return array*/

$country = $addrDetailsArr['geoplugin_countryName'];

Then, how to get locations of the city in selected field using this

Feel free to use this IP-Api . It is free. Data returned will give you the local and other details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM