Installation
ubuntu 14.04
Install libdatrie
// sudo apt-get install libdatrie-dev
Install trie_filter extension
> git clone > cd php-ext-trie-filter > phpize > ./configure --with-php-config=/usr/bin/php-config > make > make install//添加php扩展,extension=trie_filter.so > service php5-fpm restart > php5-fpm -m //查看
Use
Generate sensitive vocabulary
$arrWord = array('word1', 'word2', 'word3'); $resTrie = trie_filter_new(); //create an empty trie tree foreach ($arrWord as $k => $v) { trie_filter_store($resTrie, $v); } trie_filter_save($resTrie, __DIR__ . '/blackword.tree'); trie_filter_free($resTrie);
Use
$resTrie = trie_filter_load(__DIR__ . '/blackword.tree'); $strContent = 'hello word2 word1'; $arrRet = trie_filter_search($resTrie, $strContent); print_r($arrRet); //Array(0 => 6, 1 => 5) echo substr($strContent, $arrRet[0], $arrRet[1]); //word2 $arrRet = trie_filter_search_all($resTrie, $strContent); print_r($arrRet); //Array(0 => Array(0 => 6, 1 => 5), 1 => Array(0 => 12, 1 => 5)) foreach ($arrRet as $item) { echo substr($strContent, $item[0], $item[1]); //word2 word1 } $arrRet = trie_filter_search($resTrie, 'hello word'); print_r($arrRet); //Array() trie_filter_free($resTrie);
The above is the content of using third-party extension trie_filter for php sensitive word filtering. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!
Related articles:
An efficient sensitive word filtering method (PHP)
Use PHP to extend trie_filter to do Chinese sensitivity Word filtering
PHP implements filtering sensitive words in message messages

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

WebStorm Mac version
Useful JavaScript development tools
