过滤文字中的脏话

时间:2019-04-25 15:04:02

标签: php

当我显示数据库中的注释时,您好我试图从注释中过滤掉脏话

这是我的代码:

<?php
function filterwords($text){
$filterWords = array('hekk','darn','fut');
$filterCount = sizeof($filterWords);
for($i=0; $i<$filterCount; $i++){
$text = preg_replace('/\b'.$filterWords[$i].'\b/ie',"str_repeat('*',strlen('$0'))",$text);

}
return $text;
}

echo filterwords($pcom['description']);
?>

我原本以为我会把这样的文本替换为“什么”,但显示为“警告:preg_replace():不再支持/ e修饰符,请使用preg_replace_callback ” 我不知道如何使用preg_replace_callback如何使用它(使用replace_callback修改代码) 还是我可以使用其他方法来过滤文本中的脏话

0 个答案:

没有答案
相关问题