下面的代码给了我一个 foreach 错误。我的代码似乎有什么问题?
$my_word = $_REQUEST['value'];
$bestMatch = array('word' => $my_word, 'match' => 2);
$result = mysql_query("SELECT keyword FROM keywords");
$storeArray = Array();
foreach ($result as $keyword) {
$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'];