You are here
Home > Php > Convert IP Address to Location in PHP

Convert IP Address to Location in PHP

Hello Friends, Today I am going to share how to Convert IP Address to Location in PHP. Actually recently I required to find Country Code from an IP Address in one of my project, and I found the solution on Internet and I thought to share with you. This code basically work on web service provided by and web service url is

Using this web service we can not only get Country code but also Country name, State, City, Address, Continent, etc. This web service also provides GPS longitude and latitude but this is not implement in the given ip_info function but you can implement if you need by having idea from ip_info function.

This web service takes IP address as parameter and gives json as response. We can call web service like can use both IPv4 and IPv6 ip addresses).

So Here is the code


Convert IP Address to Location in PHP



Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.