An efficient sensitive word filtering method (PHP) without $ badwordarray (Zhang San, Zhang Sanfeng, Zhang San Toyota); $ badword1array_combine ($ badword, array_fill (0, count ($ badword ), *); $ bb I am working in zhangsan Toyota today; $ strstrtr ($ bb, $ badword1); echo $ str; $ heiarray (China, an efficient sensitive word filtering method (PHP ):
$ Badword = array ('zhang san', 'zhang Sanfeng ', 'zhang santoyota'); $ badword1 = array_combine ($ badword, array_fill (0, count ($ badword ), '*'); $ bb = 'I am working in zhangsan Toyota today'; $ str = strtr ($ bb, $ badword1); echo $ str;
$ Hei = array ('China', 'Japan '); $ blacklist = "/". implode ("|", $ hei ). "/I"; $ str = "China is a good country"; if (preg_match ($ blacklist, $ str, $ matches) {print "found :". $ matches [0];} else {print "not found. ";}
The above is the content of an efficient sensitive word filtering method (PHP). For more information, see PHP Chinese website (www.php1.cn )!
Related Articles:
Use PHP extension trie_filter to filter Chinese sensitive words
Php sensitive word filtering using third-party extension trie_filter
Use PHP to filter sensitive words in the message