Created
July 10, 2018 16:58
-
-
Save Pamps/9c15c88d318abc4751051b3de3db45b8 to your computer and use it in GitHub Desktop.
Returns if a country is in Europe, in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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