acfcs_get_cities()

Description

This function returns an array with all cities, from a specific country or province/state (when the state parameter is provided), containing a row id, a city name, state code and state name.

Usage

  1. $cities = acfcs_get_cities( 'NL' );

If you provide the second parameter, the state code, results are limited to that particular state.

  1. $cities = acfcs_get_cities( 'NL', 'NH' );

Returns

  1. array {
  2.   'id' => string 'database row id',
  3.   'city_name' => string 'Amsterdam',
  4.   'state_code' => string 'NL-NH',
  5.   'state_name' => string 'Noord-Holland',
  6. }

Arguments

  • (string) - $country_code (required)
    Country code (exactly 2 characters).
  • (bool) - $state_code (optional)
    State code (min. 1 / max. 3 characters) | default false.
  • (bool) - $show_labels (optional)
    Whether to show a text in the first option (used for dropdowns) | default false.

Defined in

inc/acfcs-functions.php - line 125

Used in