Skip to content

Instantly share code, notes, and snippets.

@tatic0
Created February 7, 2013 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatic0/4730465 to your computer and use it in GitHub Desktop.
Save tatic0/4730465 to your computer and use it in GitHub Desktop.
parse a list of IPs and return the country where the IP is using GeoIP
<?php
error_reporting(0);
$data = file('failIP.text');
foreach ($data as $line) {
$host = trim($line);
$country = geoip_country_name_by_name($host);
if ($country) {
echo 'Host '.$host. ' is located in: '.$country. "\n";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment