1:简单敏感词过滤
$badword = array(
'张三','张三丰','张三丰田'
);
$badword1 = array_combine($badword,array_fill(0,count($badword),'*'));
$bb = '我今天开着张三丰田上班';
$str = strtr($bb, $badword1);
echo $str;
2:使用PHP组件
lustre/php-dfa-sensitive
安装组件
composer require lustre/php-dfa-sensitive
php实现基于确定有穷自动机算法的铭感词过滤