function countries_api_get_name in Country codes API 6
Same name and namespace in other branches
- 5 countries_api.module \countries_api_get_name()
ISO 3166-1-alpha-#n code to country name API function
Parameters
$code: Either an iso2 or iso3 Country Code to search by.
Return value
string Returns country name as string.
2 calls to countries_api_get_name()
- CountriesAPITestCase::test_countries_api_get_name in tests/
countries_api.test - Function to test countries_api_get_name() results
- CountriesAPITestCase::test_invalid_countries_api_get_name in tests/
countries_api.test - Function to test countries_api_get_name() results with invalid name
File
- ./
countries_api.module, line 75 - Countries API provides an API for official and up-to-date ISO 3166 country codes (alpha-2 and alpha-3) and names (official short names).
Code
function countries_api_get_name($code) {
if (drupal_strlen(trim($code)) == 2) {
return countries_api_iso2_get_name($code);
}
elseif (drupal_strlen(trim($code)) == 3) {
return countries_api_iso3_get_name($code);
}
return NULL;
}