Find IP address location in php

Hello Friends In this tutorial I am going to show you how to Find IP address location in php, has provided a open api to get ip address details in array format, You can send request to with ip address and it’ll return IP address details in serialize format. It is also helpful If you are working on multi lingual project or you are looking for a solution to change website theme banner as per country location, then this tutorial is useful for you. By the below script you can find the user’s ip country, country code, currency, state and latitude , langitude to display ip location on map.

I have created simple online program to find IP address location and displayed on google map. You can download full script and change it as per your need.
First of all create a simple php function to send request on with ip address and parse response in array format.

function ipInfo($ip) {
	if(isset($ip)) {
      $data = unserialize(file_get_contents(''.$ip));
	   if($data['geoplugin_status'] == '200') {
	   	return $data;
	   } else {
	   	echo "Bad request!, Error code is ".$data['geoplugin_status']; 
	} else {
		echo "IP is not set!"; 

Now all done you only need to pass Ip Address in this function and it’ll return ip address details in array format.


In the response you’ll see lot’s of data like Ip address region, country, country code, currency, currency symbol, latitude and longitude etc..

See the online demo and download full source code.



If you like this post please don’t forget to subscribe my public notebook for more useful stuff