Skip to content

Instantly share code, notes, and snippets.

@Pamps
Created July 10, 2018 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Pamps/9c15c88d318abc4751051b3de3db45b8 to your computer and use it in GitHub Desktop.
Save Pamps/9c15c88d318abc4751051b3de3db45b8 to your computer and use it in GitHub Desktop.
Returns if a country is in Europe, in PHP
<?php
// Returns if a country is in Europe
// Pass in country name or code e.g. 'Spain' or 'ES'.
function country_is_in_europe( $country ) {
// Our list of countries
$countries = array(
'AT' => 'Austria',
'BE' => 'Belgium',
'BG' => 'Bulgaria',
'HR' => 'Croatia',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'DK' => 'Denmark',
'EE' => 'Estonia',
'FI' => 'Finland',
'FR' => 'France',
'DE' => 'Germany',
'GR' => 'Greece',
'HU' => 'Hungary',
'IE' => 'Ireland',
'IT' => 'Italy',
'LV' => 'Latvia',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'MT' => 'Malta',
'NL' => 'Netherlands',
'PL' => 'Poland',
'PT' => 'Portugal',
'RO' => 'Romania',
'SK' => 'Slovakia',
'SI' => 'Slovenia',
'ES' => 'Spain',
'SE' => 'Sweden',
'GB' => 'United Kingdom'
);
return array_key_exists($country, $countries) || in_array($country, $countries);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment