我试图让这段代码正常工作,但我一生都无法让它继续下去......我想要一个显示“你的意思是什么”的搜索。有了代码,我得到了它“你的意思是:数组 l:6”我在这里有什么问题?
$my_word = $_REQUEST['value'];
$bestMatch = array('word' => $my_word, 'match' => 2);
$result = mysql_query("SELECT keyword FROM athena");
while ($keyword = mysql_fetch_array($result)) {
$lev = levenshtein ($keyword, $my_word, 1, 2, 1);
if (!isset($lowest) || $lev < $lowest) {
$bestMatch = array('word' => $keyword, 'match' => $lev);
$lowest = $lev;
}
}
if ($bestMatch['match'] > 0)
echo 'Did you mean: <strong>'.$bestMatch['word'].'</strong> l:'.$bestMatch['match'];