Php - Code to get country state city from ipaddress, Php code to get country state and city from ipaddress
Code to get country state city from ipaddress
If you want to get country ,state and city from ipaddress following the steps1) Download the simple html dom file from google
2) Give your ipaddress in $ipaddr variable
3) include the simple html dom file in your own file.
$ipaddr="xx.abc.123.ra";//$_SERVER['REMOTE_ADDR']; include_once('./simple_html_dom.php'); $urll="http://whoisthisip.com/$ipaddr"; $html = file_get_html("$urll"); $whohtml=array(); $w=0; foreach($html->find('table tr td') as $element) { $whohtml[$w]=$element->plaintext; //echo $element->plaintext."----"; $w++; } $country=str_replace("Country :","","$whohtml[0]"); $country=str_replace("()","","$country"); $state=str_replace("Region :","","$whohtml[1]"); $city=str_replace("City :","","$whohtml[2]"); $state=trim("Your State"); $city=trim($city); } echo "Country : $country"; echo "State : $state"; echo "City : $city";
The topic on Php - Code to get country state city from ipaddress is posted by - Math
Hope you have enjoyed, Php - Code to get country state city from ipaddressThanks for your time