Home >Backend Development >PHP Problem >How to implement sensitive word replacement in php

How to implement sensitive word replacement in php

藏色散人
藏色散人Original
2020-08-08 10:42:193388browse

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.

How to implement sensitive word replacement in php

Recommended: "PHP Video Tutorial"

This article uses examples to explain how to replace sensitive words in PHP *

Code:

<?php
$badword = array(
    &#39;魔客吧&#39;,&#39;www.moke8.ccom&#39;
);
$badword1 = array_combine($badword,array_fill(0,count($badword),&#39;*&#39;));
$bb = &#39;我的网站的名字叫做魔客吧,我的网站的网址是www.moke8.com&#39;;
$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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn