Search code examples
phpiso-3166

How to get ISO 3166-1 compatible country code?


I am working on displaying list of timezones by country name.

As answered here: Country to timezones in PHP/Zend Framework

I am thinking to call DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'US') to list all timezones by country.

Is there any easy way to get list of ISO 3166-1 compatible country codes and their corresponding names in PHP(PHP 5.3)?


Solution

  • check out the most extensive and up-to-date list I could find:

    http earth-info.nima.mil/gns/html/gazetteers2.html (old link see below)

    they offer an xls download which contains the following columns:

    FIPS      10-4  ISO 3166 digraph    ISO 3166 trigraph   ISO 3166 numeric    TLD IOC SOVEREIGNTY
    

    (check out the 4th sheet in the xls file)

    Update 2016: the link is dead, try this: http://geonames.nga.mil/gns/html/