This could be useful to someone else:
This simple function takes a country code as parameter and returns TRUE if it’s in European Union (EU) or FALSE otherwise.
function isEU($countrycode) {
$eu_countrycodes = array(
'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'EL',
'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV',
'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'
);
return (in_array($countrycode, $eu_countrycodes));
}
Could be useful in online shops for example.
Thanks for sharing your code, but there is a mistake. ‘CH’ is not in EU, and you should remove it and add ‘HR’ to the list.
Thank you. I updated the function.
Thanks for this function! GR seems to be missing in that list though and HR is not aligned with the sorting of the others.
Thanks Lennard, function is updated
Thanks for the fix! Another missing one I spotted: LU (Luxembourg)
no… Luxembourg is there, maybe you have to scroll a little bit to the right side
but we can remove Great Britain today…
smalll improvement
function isEU($countrycode) {
$eu_countrycodes = array(
‘AT’, ‘BE’, ‘BG’, ‘CY’, ‘CZ’, ‘DE’, ‘DK’, ‘EE’, ‘EL’,
‘ES’, ‘FI’, ‘FR’, ‘GR’, ‘HR’, ‘HU’, ‘IE’, ‘IT’, ‘LT’, ‘LU’, ‘LV’,
‘MT’, ‘NL’, ‘PL’, ‘PT’, ‘RO’, ‘SE’, ‘SI’, ‘SK’
);
return (in_array(strtoupper($countrycode), $eu_countrycodes));
}