Hi,

I need to get the nearest neighbor state based on the IP address of the current state. I have done some research and found Geo plugin, which gives the state information based on the IP address. So now i need the States nearer to that IP address.How can i do it in PHP..? can any one suggest me..

Thank you.

Mine is more an idea than a solution: you will probably need the position (in coordinates) inside the state, in order to evaluate the nearest border. For example, in MySQL, having the coordinates of each city, you can query and get the result for the cities in a defined range, the first of the result set outside the national border will be in the nearest state.

But the IP is not always the correct source city, a part proxies, sometimes you get the IP of a Tier 2 (or 3) node, for example if you check for italians IPs those can be matched to cities distant up to 800km from the real user location, depending on the node that will send the request out.

The Geolocation API can probably be more accurate, check for:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.