I'm using the autocompleter of "http://www.devbridge.com/sourcery/components/jquery-autocomplete/" but in a previous version because of its lightweight and speed. the version I used can be found here: https://code.google.com/p/jquery-autocomplete/source/browse/
Within that I try to receive results with
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
$(function() {
$("#ac1").autocomplete('search.php', {
selectFirst: true
});
$("#flush").click(function() {
var ac = $("#ac1").data('autocompleter');
if (ac && $.isFunction(ac.cacheFlush)) {
ac.cacheFlush();
} else {
alert('Error flushing cache');
}
});
the data.php is very easy structured:
$data = array(
"Berlin" => "10178",
"Hamburg" => "20038",
"München" => "80331",
and the search.php file is the following:
<?php
include 'data.php';
include 'data.php';
function autocomplete_format($results) {
foreach ($results as $result) {
echo $result[0] . '|' . $result[1] . "
";
}
}
if (isset($_GET['q'])) {
$q = strtolower($_GET['q']);
if ($q) {
foreach ($data as $key => $value) {
if (strpos(strtolower($key), $q) !== false) {
$results[] = array($key, $value);
}
}
}
}
$output = 'autocomplete';
if (isset($_GET['output'])) {
$output = strtolower($_GET['output']);
}
if ($output === 'json') {
echo json_encode($results);
} else {
echo autocomplete_format($results);
}
Now I got 2 Questions:
As you see, the data.php consists special charakters like "ü" and "ö". these arent shown correctly in the result. could anybody help me and tell how to fix this?
and the second question is how to echo the second part after the city name and the "=>" regarding to the searched city?
Thank you very much for helping