Countries API
Provides an API for official ISO 3166 country codes and names.
Please visit the Maintenance agency website on http://www.iso.org/iso/country_codes/ for more information about ISO 3166.
Global operations
function countries_api_get_list() : array
This function returns the full list of official ISO country codes and names.
- Parameter(s)
- None
- Returns
- An indexed array containing the list of each official ISO country codes and name as associative arrays, using the following keys:
- name - Returns the country short name.
- iso2 - Returns the country ISO 3166-1-alpha-2 code.
- iso3 - Returns the country ISO 3166-1-alpha-3 code.
function countries_api_get_name($code) : string
This function gets either an ISO 3166-1-alpha-2 or ISO 3166-1-alpha-3 code in parameter and returns the corresponding country short name.
- Parameter(s)
- $code - An ISO 3166-1-alpha-2 or ISO 3166-1-alpha-3 code as a string.
- Returns
- The corresponding country short name as a string. In case the country code doesn't match any country, null is returned.
function countries_api_get_country($code) : array
This function gets either an ISO 3166-1-alpha-2 or ISO 3166-1-alpha-3 code in parameter and returns an array representing the corresponding country.
- Parameter(s)
- $code - An ISO 3166-1-alpha-2 or ISO 3166-1-alpha-3 code as a string.
- Returns
- An associative array, using the keys as described in countries_api_get_list(). In case the country code doesn't match any country, null is returned.
ISO 3166-1-alpha-2 code operations
function countries_api_iso2_get_name($code) : string
This function gets an ISO 3166-1-alpha-2 code in parameter and returns the corresponding country short name.
- Parameter(s)
- $code - An ISO 3166-1-alpha-2 code as a string.
- Returns
- The corresponding country short name as a string. In case the country code doesn't match any country, null is returned.
function countries_api_iso2_get_iso3($code) : string
This function gets an ISO 3166-1-alpha-2 code in parameter and returns the corresponding ISO 3166-1-alpha-3 code.
- Parameter(s)
- $code - An ISO 3166-1-alpha-2 code as a string.
- Returns
- The corresponding ISO 3166-1-alpha-3 code as a string. In case the country code doesn't match any country, null is returned.
function countries_api_iso2_get_country($code) : array
This function gets an ISO 3166-1-alpha-2 code in parameter and returns an array representing the corresponding country.
- Parameter(s)
- $code - An ISO 3166-1-alpha-2 code as a string.
- Returns
- An associative array, using the keys as described in countries_api_get_list(). In case the country code doesn't match any country, null is returned.
ISO 3166-1-alpha-3 code operations
function countries_api_iso3_get_name($code) : string
This function gets an ISO 3166-1-alpha-3 code in parameter and returns the corresponding country short name.
- Parameter(s)
- $code - An ISO 3166-1-alpha-3 code as a string.
- Returns
- The corresponding country short name as a string. In case the country code doesn't match any country, null is returned.
function countries_api_iso3_get_iso2($code) : string
This function gets an ISO 3166-1-alpha-3 code in parameter and returns the corresponding ISO 3166-1-alpha-2 code.
- Parameter(s)
- $code - An ISO 3166-1-alpha-3 code as a string.
- Returns
- The corresponding ISO 3166-1-alpha-2 code as a string. In case the country code doesn't match any country, null is returned.
function countries_api_iso3_get_country($code) : array
This function gets an ISO 3166-1-alpha-3 code in parameter and returns an array representing the corresponding country.
- Parameter(s)
- $code - An ISO 3166-1-alpha-3 code as a string.
- Returns
- An associative array, using the keys as described in countries_api_get_list(). In case the country code doesn't match any country, null is returned.
License
This module is licensed under the terms of the GNU General Public License version 2.
This module was created by horsconcept, Alexandre Kraft.
