Keyword filtering is very simple. the content to be filtered is stored in an array or a document. when the user submits the content, we can determine whether to use preg_match or istrpos. the specific method is as follows. for example, the code is as follows: filter the blacklist keyword function fu... keyword filtering is very simple. the content to be filtered is stored in an array or a document. when the user submits the content, we can determine whether to use preg_match or istrpos. the specific method is as follows.
For example, the code is as follows:
// Filter the blacklist keyword function
Function check _ ($ data) {$ keywords = "are you a great God | Hello | go to death"; if (preg_match ("/$ keywords/I", $ data )) {return;} else {return $ data ;}}
The keyword is stored in txt and txt files in this form: | gambling machine | selling blood | selling kidney | selling organs | cornea, the code is as follows:
"; // Var_dump ($ w); // $ words =" aaa | bbb | ccc | ddd | eee "; $ matched = preg_replace ('/'. $ word. '/I', '***', $ string); return $ matched; // open source code phprm.com} $ content = "I want aaafsdfbbb "; if ($ result = Filter_word ($ content ,'. /words.txt ') {echo $ result; echo "replaced successfully";} else {echo "failed to be replaced! ";}
Tutorial link:
Reprint at will ~ However, please keep the tutorial address★