2012-06-22 69 views
1

我有這個PHP代碼來突出顯示搜索結果上的查詢。突出顯示在特殊字符中的搜索結果中的查詢

if (isset($_REQUEST['k'])){ 
     $k = htmlentities($_REQUEST['k']); 
     $position = 0; 

     while ($position = stripos($text, $k, ($position)?$position+30:0) and $position !== false){ 
      $text = substr_replace($text, '</span>', $position + strlen($k), 0); 
      $text = substr_replace($text, '<span class="highlight">', $position, 0); 
     } 
    } 

的問題是,如果我搜索類似「咖啡館」,則可能是「咖啡廳」(E)和條款不會被高亮顯示結果...

如何解決這個?

謝謝!

+2

可能重複http://stackoverflow.com/questions/3582916 /重音不敏感的子串匹配) –

回答

1

這裏是包括什麼,我想你想acheive正常化陣列和幾個例子的鏈接 - http://ie2.php.net/strtr

[不區分重音串匹配(的
相關問題