Multiple IF Statements or Array?

Hello forum!

I have a custom field in Wordpress which is populated with a country code: GB, IT, ES… (around 40 of them)…

Looking for efficient PHP code to display to user the respective country’s name for each country code…

Any help is much appreciated…


I’d say the easiest way is an array

$countries = array(
    'BE' => 'Belgium',
    'NL' => 'The Netherlands',
    'GB' => 'Great Brittain',
    'US' => 'USA',
    // etc

$county = array_key_exists($country_code, $countries) ? $countries[$country_code] : 'Unknown country';

thanks - this is quite neat!