How to implement sensitive word replacement in php

藏色散人
Release: 2023-03-04 07:06:01
Original
3363 people have browsed it

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;
?>
Copy after login

Output:

我的网站的名字叫做*,我的网站的网址是*
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template