Surt Surt - 2 months ago 25x
PHP Question

PHP intl country code 2 chars to country name

I'm triying to convert, using PHP, 2 characters country code (ISO 3166-1) to country names, or intl country codes, so I can translate the country name.


needs locale codes for languages (
) and all I have is the 2 characters country code.
I don't want to rely on Webservices, but I can think on the geoip extension (I can't find a solution using it anyway)

Is there any way to get the 2 chars country code and convert it to localiced country name in PHP without using webservices or external resources?

(I was using zend_locale some time ago, but zf2 does not have that functionality)


You don't have to have a fully-formed locale for the first parameter. This makes the function useful for getting the country name from any locale:

var_dump(Locale::getDisplayRegion('-US', 'fr'));

string '√Čtats-Unis' (length=11)