📌  相关文章
📜  php 检查字符串是否包含数组中的单词 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:44.276000             🧑  作者: Mango

代码示例1
$string = "This dude is a mean mothertrucker";
$badwords = array('truck', 'shot', 'ass');
$banstring = ($string != str_ireplace($badwords,"XX",$string))? true: false;
if ($banstring) {
   echo 'Bad words found';
} else {
    echo 'No bad words in the string';
}