You are here

function getlocations_fields_country_autocomplete in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/getlocations_fields.functions.inc \getlocations_fields_country_autocomplete()

autocomplete for country

Parameters

string $string:

Return value

Returns country names

1 string reference to 'getlocations_fields_country_autocomplete'
getlocations_fields_menu in modules/getlocations_fields/getlocations_fields.module
Implements hook_menu().

File

modules/getlocations_fields/getlocations_fields.functions.inc, line 445
getlocations_fields.functions.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_country_autocomplete($string = '') {
  $matches = array();
  if ($string) {
    $countries = getlocations_get_countries_list();
    foreach ($countries as $country) {
      $s = drupal_strtolower($string);
      $c = drupal_strtolower($country);
      preg_match_all("/^{$s}/", $c, $m);
      if (count($m[0])) {
        $matches[$country] = $country;
      }
    }
  }
  drupal_json_output($matches);
}