前提在于已经定义好了一个敏感词库类型为数组类型
下面看代码:
# 循环敏感词
$str = '';
foreach ( $data as $k => $v ){
for ( $i=0; $i<count( $data ); $i++ ){
if( substr_count( $msg , $v ) > 0 ){
return $this -> fail( '内容包含敏感词' );
}else{
return json_encode( [ 'status' => '100' , 'msg' => '通过' ] , 256 );
}
// echo $msg;
}
}