php - explode and in_Array search not working -
possible duplicate:
explode , 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 $wordtmp) { if (!empty($wordtmp) && !in_array($wordtmp, $omit) && strlen($wordtmp) >= $min_count) { $words[] = $wordtmp; } } return $words; } $filter_array = explode("\n", words list separated \n new line here); print_r(processcontent('string gere filtering', $min_word_length, $filter_array));
the variable $filter_array passed in exclude_list merged omit variable not filtered in return value. first $omit value filtered. there wrong in code??
you missing " in 16th line.
$filter_array = explode("\n", "words list separated \n new line here");
Comments
Post a Comment