判断数组中是否存在敏感词

前提在于已经定义好了一个敏感词库类型为数组类型
下面看代码:

# 循环敏感词
        $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;
            }

        }

猜你喜欢

转载自blog.csdn.net/weixin_44309184/article/details/85318653