You are here

function regions_api_iso2_get_array in Country codes API 6

Function to get a region by iso2 country name

Parameters

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

Return value

array|null Returns an array of regions or NULL if no results found

1 call to regions_api_iso2_get_array()
RegionsAPITestCase::test_regions_api_iso2_get_array in contrib/regions_api/tests/regions_api.test
Test that the links are added to the page (no JS testing).

File

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

Code

function regions_api_iso2_get_array($iso2) {
  $result = db_query("SELECT rid, iso2, name, abbreviation FROM {regions_api_regions} WHERE iso2 = '%s'", $iso2);
  $regions = array();
  while ($row = db_fetch_array($result)) {
    $regions[] = $row;
  }
  if (count($regions) == 0) {
    return NULL;
  }
  return $regions;
}