function location_get_cities in Location 7.3
Parameters
string $country: Two letter ISO country code.
string $city: City.
Return value
array Returns an array of matches.
1 call to location_get_cities()
- _location_city_autocomplete in ./
location.module - Create a list of City from a given country.
File
- ./
location.module, line 1130 - Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…
Code
function location_get_cities($country, $city) {
$matches = array();
$query = db_select('zipcodes', 'z');
$result = $query
->fields('z', array(
'city',
))
->condition(db_and()
->condition('z.city', "%{$city}%", 'LIKE')
->condition('country', $country, '='))
->range(0, 20)
->execute();
foreach ($result as $obj) {
$matches[$obj->city] = check_plain($obj->city);
}
return $matches;
}