2011-02-18 3 views
0

가능한 중복 : 여기에 변수 $ filter_array도 통합되어 exclude_list에 전달됩니다 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; 
} 
$filter_array = explode("\n", words list separated by \n new line here); 
print_r(processContent('String gere for filtering', $min_word_length, $filter_array)); 


explode and in_Array search not working

codepad 변수를 생략하지만 반환 값으로 필터링되지 않습니다. 첫 번째 $ 생략 값만 필터링됩니다. 코드에 문제가 있습니까?

+0

예가 답을 얻을 수 없었다. 같은 질문을 게시 – Yalamber

+0

반복 ... 당신이 빨리 답을 얻을 수 있도록에 추가 정보를 편집하지 않습니다 귀하의 원래 질문 –

+0

이제 괜찮아 질 것입니다. – Yalamber

답변

0

당신은 당신의 16 라인에서 "누락되었습니다.

 


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

 
+0

양식 게시물에서 변수가있을 것입니다. – Yalamber

관련 문제