prepare(" SELECT location_id AS `id`, Concat( location_name, ', ', location_address, ', ', location_town) AS `label`, location_name AS `value`, location_address AS `address`, location_town AS `town`, location_state AS `state`, location_postcode AS `postcode`, location_country AS `country` FROM $locations_table WHERE ( `location_name` LIKE %s ) $location_cond LIMIT 10 ", $term); $locations_array = $wpdb->get_results($sql); echo EM_Object::json_encode($locations_array); /* $return_string_array = array(); foreach($locations_array as $location){ $return_string_class = array(); foreach($location as $key => $value ){ $return_string_class[] = "$key : '".addslashes($value)."'"; } $return_string_array[] = '{'. implode(',', $return_string_class) .'}'; } echo '['. implode(',', $return_string_array) .']'; */ ?>