Home > php教程 > php手册 > body text

一个高效的敏感词过滤方法(PHP)

PHP中文网
Release: 2017-03-22 14:29:20
Original
8238 people have browsed it

一个高效的敏感词过滤方法(PHP) :

$badword = array(  
    '张三','张三丰','张三丰田'  
);  
$badword1 = array_combine($badword,array_fill(0,count($badword),'*'));  
$bb = '我今天开着张三丰田上班';  
$str = strtr($bb, $badword1);  
echo $str;
Copy after login
$hei=array(  
'中国',  
'日本'  
);  
$blacklist="/".implode("|",$hei)."/i";  
$str="中国一是一个很好的国家";  
if(preg_match($blacklist, $str, $matches)){  
    print "found:". $matches[0];  
  } else {  
    print "not found.";  
  }
Copy after login

以上就是一个高效的敏感词过滤方法(PHP)的内容,更多相关内容请关注PHP中文网(www.php.cn)!

相关文章:

利用PHP扩展trie_filter做中文敏感词过滤

php敏感词过滤使用第三方扩展trie_filter

PHP实现过滤留言信息中的敏感词

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template