From Google and Stack Overflow
I searched your query on Google and found a great Stack Overflow thread. In summary here is the solutions:
You can use APIs:
Or you can use a local database on your server, it does need to be updated regularly though.
If you have money, you can use the Maxmind GeoAPI built-in to your PHP server.
You want to check the original stack overflow thread here http://stackoverflow.com/questions/3...dress-with-php