How to detect visitor’s country using his IP address
Software77 is perhaps the first company which created IP to country database. On their website you can grab the DB in CSV and GeoIP format with a few example scripts in various languages to use the DB. I couldn’t find anything in PHP to operate on their GeoIP format DB, so I converted the CSV version to PHP arrays and created a simple script to handle this new format.