Search code examples
phpzend-frameworkzend-locale

How to convert a country string to its ISO 3166-1 code using Zend?


Does anybody know if it's possible to use Zend_Locale to get the ISO 3166-1 code for a country if you have the country name as a string? For example I have "Nederland" so I would like to get "NL".


Solution

  • You should have a look at Zend_Locale::getTranslation(). You may get a list (a simple array) of country names - and then you may use array_search() to get the needed "country-key"!