2011-02-18 43 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");