Wednesday, August 29, 2012

how to get country name through ip using php

function countrynameFromIP($ipAddr)
ip2long($ipAddr)== -1 || ip2long($ipAddr) === false ? trigger_error("Invalid IP", E_USER_ERROR) : "";
$ipDetail=array(); //initialize a blank array

$xml = file_get_contents("".$ipAddr);
//get the country name inside the node and
$ipDetail['country_code']=$cc_match[1]; //assing the country code to array
//return the array containing city, country and country code
return $ipDetail;
echo $IPDetail=countrynameFromIP($_SERVER['REMOTE_ADDR']);
if you helpful my code please donate some few amount to
developing and free to post.

No comments:

Post a Comment