2011-02-18 35 views
0

可能重複:
explode and in_Array search not working爆炸,in_Array搜索不工作

鍵盤這裏http://codepad.org/ZQz0Kn3R

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; 
} 
$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值被過濾。代碼中有什麼錯?

+0

是沒能回答有。 – Yalamber 2011-02-18 12:00:16

+0

重複發佈同樣的問題不會幫你找到答案更快了......編輯任何額外信息進入你原來的問題 – 2011-02-18 12:15:25

回答

0

你缺少「在16日線。

 


$filter_array = explode("\n", "words list separated by \n new line here");