我正在尝试匹配从mysql数据库表中检索到的希伯来语禁用的单词与希伯来语字符串$_POST['content'],对于英语单词(如果在希伯来语字符串$_POST['content']中使用),它给匹配,但希伯来语单词没有运气。你能帮我修改下面的代码,在给定的字符串中搜索禁止的希伯来语单词吗?所有的数据源都经过了UTF-8格式的检查。
<?
$banned_words=array();
while($loc=mysql_fetch_array($loc_query))
{
$banned_words[$k]=stripslashes(utf8_decode($loc["sb_word"]));
$k=$k+1;
}
$matches = array();
$matchFound = preg_match_all(
"/\b(" . implode($banned_words,"|") . ")\b/u",
$_POST['content'],
$matches
);
if ($matchFound)
{
$words = array_unique($matches[0]);
$word_status=1;
}
?>发布于 2012-03-06 05:07:12
\b不支持unicode,您应该使用Unicode character properties。有关帮助,请参阅this answer
https://stackoverflow.com/questions/9573282
复制相似问题