【发布时间】:2011-05-25 21:30:42
【问题描述】:
我正在尝试找出一个字符串是否与我的数组 IE 中的任何坏词匹配:
$badWords = Array('bad', 'words', 'go', 'here');
$strToCheck = "checking this string if any of the bad words appear";
if (strpos($strToCheck, $badWords)) {
// bad word found
}
问题是 strpos 只能检查一个字符串而不是一个数组,有没有一种方法可以做到这一点而不循环遍历 badwords 数组?
【问题讨论】:
标签: php