//I am just doing a test. If you use a string similar to tmd again, you must pay attention. If the characters in the string appear in $StartReplaceHtml or $EndReplaceHtml, you need to modify the following preg_replace. Rules
$CheckedMessage="Hello!! He X's...He...X...'s...How are you m d "; //the message to be checked
echo $CheckedMessage. "
";
$CheckedWords=array("his If he, X, comes out, you don’t need to set the filter character to "his ="";
$EndReplaceHtml="";
$CheckOther= true;//Set the flag bit to determine whether to display a single character. If set to true, the following if(strstr...) is not needed
for($i=0;$i
here $CheckedMessage=eregi_replace($CheckedWords[$i],$StartReplaceHtml. $CheckedWords[$i].$EndReplaceHtml,$CheckedMessage);//If you only filter strings such as "other X" (it is a string, not a single character), you can write this sentence directly and set $CheckOther to false
}
if($CheckOther == true){
$CharStringLength = strlen($CheckedWords[$i]);
for($j=0;$j<$CharStringLength;$j++ ; Add one
$AssumeLength++;
$CheckedMessage=preg_replace("/(? will not be replaced. If filtering is required Characters dropped in $StartReplace or $EndReplaceHtml need to modify the rules, otherwise there will be garbled characters if($AssumeLength!=1){//If the currently intercepted character is a Chinese character
$j++; 🎜> !
?>
http://www.bkjia.com/PHPjc/314989.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/314989.html
TechArticle