Hey,
you can do this:
<?php
error_reporting( E_ERROR | E_WARNING | E_PARSE );
$ip_addr = "212.135.179.221";
$url= "http://www.nic.com/cgi-bin/whois.cgi?query=$ip_addr";
$fp = fopen($url,"r");
if( ! $fp )
{
die("warning: failed to connect to $url");
}
else
{
while( ! feof($fp) )
{
$str .= fgets($fp,4096);
}
if( ! $str )
{
die("warning: \$str is empty!");
}
}
if( ! fclose($fp) )
{
die("warning: could not close \$fp!");
}
if( preg_match("/country:\s+([A-Za-z]{2,4})/",$str,$re_match) )
{
$re_match[0] = str_replace("country: ","",$re_match[0]);
echo "The i.p. address ".$ip_addr." is located in country".$re_match[0]."\n";
}
?>
Although this will only get the country (if stated).