Copy code The code is as follows:
$badword = array(
'Zhang San','Zhang Sanfeng',' Zhang San Toyota'
);
$badword1 = array_combine($badword,array_fill(0,count($badword),'*'));
$bb = 'I drove Zhang San Toyota today Go to work';
$str = strtr($bb, $badword1);
echo $str;
Copy code The code is as follows:
$hei=array(
'China',
'Japan'
);
$blacklist="/".implode("|",$hei)."/i";
$str="China is a very good country";
if(preg_match($blacklist, $str, $matches)){
print "found:". $matches[0];
} else {
print "not found.";
}
http://www.bkjia.com/PHPjc/747678.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/747678.htmlTechArticleCopy the code The code is as follows: $badword = array( 'Zhang San','Zhang Sanfeng','Zhang San Toyota' ); $badword1 = array_combine($badword,array_fill(0,count($badword),'*')); $bb = 'I drove Zhang San today...
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