斯洛伐克語中有兩個非常相似的表達式存在問題。我試圖替換html鏈接的表達式,下面是我的示例代碼。我在陣列中有大約90個字。preg_replace與兩個相似的單詞
// mysql query above.
for($i=1;$i<=$datas[1];$i++) {
$regex[] = '/('.htmlentities($rows['title'], ENT_QUOTES, 'UTF-8').')/i';
$wrl[] = '<a href="'.URL.'link/'.urlencode($rows['alias']).'" class="underscored">'.strtolower($rows['title']).'</a>';
}
$content = preg_replace($regex, $wrl, $content);
但我有一個非常相似的單詞的問題; (nenasytene mastne kyseliny,nasytene mastne kyseliny)。 preg_replace從較長的單詞中刪除ne,這會導致單詞鏈接到錯誤的文章。
非常感謝。它完美無瑕。 – InsaneSVK