开发者

explode and in_Array search not working [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

explode and in_Array search not working

codepad here 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));

The variable $filter_array is p开发者_开发技巧assed in to the exclude_list also is merged to omit variable but does not get filtered in return value. only first $omit value is filtered. Is there something wrong in code??


You are missing " in your 16th line.



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


0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜