function countries_api_get_list in Country codes API 6
Same name and namespace in other branches
- 5 countries_api.module \countries_api_get_list()
Function to return an associative array of all countries.
Parameters
$reset: Whether to reset the internal countries_api_get_list cache.
Return value
array associative array of all countries
3 calls to countries_api_get_list()
- CountriesAPITestCase::test_countries_api_get_list in tests/
countries_api.test - Function to validate format (and presence of) countries from countries_api_get_list()
- CountriesAPITestCase::test_count_countries_api_get_list in tests/
countries_api.test - Function to validate length of countries list is greater than 0
- countries_api_get_array in ./
countries_api.module - Function to return an associative array of countries with key/values based on args Can be used to get results for FAPI form options.
File
- ./
countries_api.module, line 274 - 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_list($reset = FALSE) {
static $countries;
if ($reset || !isset($countries)) {
$countries = array();
$result = db_query("SELECT iso2, iso3, name, printable_name, numcode FROM {countries_api_countries} ORDER BY printable_name");
while ($row = db_fetch_array($result)) {
$countries[] = $row;
}
}
return $countries;
}