function cleanWords1($text) {
//根据个人需要添加需要过滤的词汇,以"|"作为分隔符
$badword = "敏感字|敏感字|敏感字|敏感字|敏感字";
$badwords = explode('|',$badword);
foreach($badwords as $v){
$text = str_replace($v,'**',$text);
}
return $text;
}
function cleanWords2($text) {
//根据个人需要添加需要过滤的词汇,以"|"作为分隔符
$badword = "敏感字|敏感字|敏感字|敏感字|敏感字";
return preg_replace("/$badword/i",'**',$text);
}
$string="敏感字符串";
echo cleanWords1($string).' ';
echo cleanWords2($string);
?>
|