if ($loc != "") { if (strpos($loc, ",")) { //there's a comma $locs = explode(',', $loc); //create an array of locations delimited by comma $types = array("route", "locality", "administrative_area_level_1", "country"); $match = false; //keep track of whether a loc type is found, needed in order to cycle through locs array many times to pref certain loc types more (ie. 1: locality 2: administrative_area_level_1 3:country) $i_type = 0; do { $i = 0; //counter to track for last element in foreach of locs; $length = count($locs); foreach ($locs as $value) { $address = urlencode($value); if (geocoder::getLocType($address) == $types[$i_type]) { $location = geocoder::getLocation($address); $formatted_address = geocoder::getFormatted($address); $match = true; break; } //end if loctype = locality if ($i == $length - 1) { //if last element and no loc type then move to next loc type and start over $i_type++; } $i++; sleep(2); //give geocoder a rest so no over_query_limit error } //end foreach locs