An efficient sensitive word filtering method (PHP)

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.