Display country, region, city using ip address in php

	$ipaddress = $_SERVER['REMOTE_ADDR'];
		//$ipaddress='203.115.97.180';
		//$json       = file_get_contents("http://ip-api.com/json");
	//$json       = file_get_contents("http://ipinfo.io/{$ipaddress}");
	//$json       = file_get_contents("http://ipinfo.io/{$ipaddress}");
		$json       = file_get_contents("http://ip-api.com/json/".$ipaddress);
		$details    = json_decode($json);
		$data['countryCode']=$details->countryCode;
		$data['region']=$details->region;
		$data['city']=$details->city;


Leave a Reply