php 敏感词汇匹配
作者:
浪子与渣男 | 来源:发表于
2020-04-14 16:17 被阅读0次 public function banwordCheck($con){
$file = $_SERVER['DOCUMENT_ROOT'].'/public/minganci.txt';; //换成你本地的敏感词汇文件
$words = file_get_contents( $file );
$fuckArr = explode('|',$words);
for($i=0;$i<count($fuckArr);$i++){
if($fuckArr[$i] == ""){
continue;// 如果内容为空则跳过本次循环
}
if(strpos($con,trim($fuckArr[$i])) != false ){
return true;//如果匹配到敏感词汇就返回敏感词汇
}
}
return false;//如果没有匹配到敏感词汇就返回 false
}
本文标题:php 敏感词汇匹配
本文链接:https://www.haomeiwen.com/subject/whetvhtx.html
网友评论