search
Homephp教程php手册一个高效的敏感词过滤方法(PHP)

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

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

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

相关文章:

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

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

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

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool