Ben
Ben is a lifelong Nintendo fan who likes to build websites, and make video games. He buys way too much Lego.
WordPress and Games
As web designers, sometimes we need to work with lists of countries. For instance there is a new EU cookie law coming into action soon – that only applies to Europe. There is a worldwide standard that gives each country a 2 letter code.
The country code standard makes it easy for developers to combine different API’s consistently (standards are good). However there’s loads of country codes – and in order to fulfil our legal obligations I needed a list of 2 letter country codes applicable to Europe only. So, I created a list of codes that you can see (and use) below.
For a full list of all the ISO 2 letter country codes check out the Wikipedia page on the subject.
Since I made it for myself, here’s the list as a nice handy PHP array as well.
<?php $eu_countries = array( 'AL', 'AD', 'AM', 'AT', 'BY', 'BE', 'BA', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GE', 'GI', 'GR', 'HU', 'HR', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MK', 'MT', 'NO', 'NL', 'PL', 'PT', 'RO', 'RU', 'SE', 'SI', 'SK', 'SM', 'TR', 'UA', 'VA', ); ?>
Awesome, Ben – very handy. Any chance you’d submit it to my cheat sheet site (cheatography.com)? You can link to it here, or create a full page / PDF version, whichever you prefer ๐
Hey Dave – would be happy to submit it. I didn’t realise your site was open to submissions. I used your original cheat sheets quite a bit so would be happy to contribute ๐
Thanks Ben – just noticed you’d added it (external links go through an approval process – sorry for the delay). Thanks very much! ๐
This is tremendously handy – thank you!
Would love to see how you use it ๐
Very useful
ps used with MySql for tax summary (and several otherplaces) :
SELECT …
IF(b.country_id NOT IN (‘”.implode(“‘,'”, EU_COUNTRIES).”‘), ‘EXEMPT’,
IF(i.tax_amount > 0.00, ‘TAXABLE’, ‘ZERO’)) as class,
… where EU_COUNTRIES is a constant
perfect use for it! ๐ I actually had to do some stuff for tax summaries a couple of days ago as well!
Important: This is a list of european countries, not EU (European Union)
Countries like Albania, Andorra, Armenia, Switzerland, Norway are not in the EU.
Ah – interesting distinction. I shall clarify in my post as well. Thanks a lot!
Hey!
Great thing this, but the country code for Poland is PL, not PO.
(See for yourself: Wikipedia)
not sure how I missed that. Thanks!
You should update the PHP copy/paste code with this too for lazy people :).
Good call – all done ๐
Thank you good sir !!!
Thanks man! But please do clarify in the post that this is not a list of EU countries but of European countries. EU rules rarely apply to Russia…
What about Serbia ๐
Hey Nikola – do you know what the code should be for Serbia? Happy to add it in!
nice
EU All: AT, BE, BG, CY, CZ, DE, DK, EE, ES, FI, FR, GB, GR, HR, HU, IE, IT, LT, LU, LV, MT, NL, PL, PT, RO, SE, SI, SK
MU All: AT, BE, CY, DE, EE, ES, FI, FR, GR, IE, IT, LT, LU, LV, MT, NL, PT, SI, SK
You forgot Liechtenstein – LI
Thanks – I’ve added it now! ๐
Much appreciated, especially the array.
Moldova (MD) is missing.
Azerbaijan (AZ) technically not in Europe but present in many European associations (like Armenia for example) is also not present.
Thank you for your work