我試圖找出一個字符串匹配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只能檢查對於一個字符串而不是一個數組,是否有一種方法可以在沒有循環遍歷字符串數組的情況下執行此操作?
看看這個功能http://2008.gr0w.com/articles /代碼/ php_bad_words_filter / – 2011-05-25 22:10:30