function countries_api_get_array in Country codes API 5
Same name and namespace in other branches
- 6 countries_api.module \countries_api_get_array()
Function to return an associative array of countries with key/values based on args Can be used to get results for FAPI form options.
Parameters
$key_format: The format of the key (a value from countries_api_formats)
$value_format: The format of teh value (a value from countries_api_formats)
Return value
array An associative array based on arguments
2 calls to countries_api_get_array()
- CountriesApiTest::test_countries_api_get_array in tests/
countries_api.test - Function to test countries_api_get_array() results
- countries_api_get_options_array in ./
countries_api.module - Function for returning an associative array useful for FAPI select elements
File
- ./
countries_api.module, line 197
Code
function countries_api_get_array($key_format = 'iso2', $value_format = 'printable_name') {
//Validate args
if (!countries_api_validate_format($key_format)) {
return false;
}
if (!countries_api_validate_format($value_format)) {
return false;
}
$countries = countries_api_get_list();
$rows = array();
foreach ($countries as $country) {
$rows[$country[$key_format]] = $country[$value_format];
}
return $rows;
}