You are here

function regions_api_iso2_get_options_array in Country codes API 6

Funtion to get an options array of country regions

Parameters

$iso2: A string corresponding to a regions ISO2 name.

1 call to regions_api_iso2_get_options_array()
regions_api_service_load in contrib/regions_api_service/regions_api_service.module
Returns an array of countries

File

contrib/regions_api/regions_api.module, line 45
Regions API provides an API for accessing country region (province/state) data.

Code

function regions_api_iso2_get_options_array($iso2) {
  $result = db_query("SELECT name, abbreviation FROM {regions_api_regions} WHERE iso2 = '%s'", $iso2);
  $regions = array();
  while ($row = db_fetch_array($result)) {
    $key = drupal_strlen($row['abbreviation']) > 0 ? $row['abbreviation'] : $row['name'];
    $value = $row['name'];
    $regions[$key] = $value;
  }
  if (count($regions) == 0) {
    return NULL;
  }
  return $regions;
}