我嘗試了preg_match的其他正則表達式問題的建議解決方案,但無濟於事。使用preg_match的正則表達式模式變量
$match = '/^(.|a|an|and|the|this|at|in|or|of|is|for|to|its|as|by)\$/';
$filteredArray = array_filter($wordArray, function($x){
return !preg_match($match,$x);
});
它適用於我包含字符串文字但我想使用一個變量,所以我可以添加更多的單詞。此版本的作品:
$filteredArray = array_filter($wordArray, function($x){
return !preg_match("/^(.|a|an|and|the|this|at|in|or|of|is|for|to|its|as|by)$/",$x);
});
我感謝任何幫助!
不知道,如果解決方案,但儘量使用雙quoutes作爲工作示例。 – Kristian 2011-12-28 21:03:26
Ups,剛剛得到它。這是因爲變量的範圍。作爲回答發帖 – Kristian 2011-12-28 21:04:07