php method to implement sensitive word replacement: first create a PHP sample file; then specify the sensitive word; then replace the sensitive word through the "strtr($bb, $badword1);" method; and finally output the replacement result through echo That’s it.
Recommended: "PHP Video Tutorial"
This article uses examples to explain how to replace sensitive words in PHP *
Code:
<?php $badword = array( '魔客吧','www.moke8.ccom' ); $badword1 = array_combine($badword,array_fill(0,count($badword),'*')); $bb = '我的网站的名字叫做魔客吧,我的网站的网址是www.moke8.com'; $str = strtr($bb, $badword1); echo $str; ?>
Output:
我的网站的名字叫做*,我的网站的网址是*
The above is the detailed content of How to implement sensitive word replacement in php. For more information, please follow other related articles on the PHP Chinese website!