確定這裏是這裏http://codepad.org/ZQz0Kn3R爆炸,in_Array搜索不工作
function processContent($content, $min_count = 2, $exclude_list = array()) {
$wordsTmp = explode(' ', str_replace(array('(', ')', '[', ']', '{', '}', "'", '"', ':', ',', '.', '?'), ' ', $content));
$words = array();
$wordsTmp2 = array();
$omit = array('and', 'or', 'but', 'yet', 'for', 'not', 'so', '&', '&', '+', '=', '-', '*', '/', '^', '_', '\\', '|');
if(count($exclude_list)>0){
$omit = array_merge($omit, $exclude_list);
}
foreach ($wordsTmp as $wordTmp) {
if (!empty($wordTmp) && !in_array($wordTmp, $omit) && strlen($wordTmp) >= $min_count) {
$words[] = $wordTmp;
}
}
return $words;
}
確定這是我的職能應該由$omit
變量過濾返回的話數組的代碼鍵盤。但是當我使用它時,第一個$omit
數組中的單詞僅被過濾,第二個從$exclude_list
合併的數據未被過濾。
我用我的功能是這樣的:
$filter_array = explode("\n", words list separated by \n new line here);
print_r(processContent('String gere for filtering', $min_word_length, $filter_array));
變量$filter_array
到exclude_list也被合併到省略變量傳遞,但不返回值得到過濾。只有第一個$omit
值被過濾。代碼中有什麼錯?
http://codepad.org/lkg9JQqJ看到這個鍵盤。同樣的錯誤 – Yalamber 2011-02-18 11:02:47