explode y la búsqueda in_Array no funciona
OK aquí está el código del teclado aquíhttp: //codepad.org/ZQz0Kn3
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;
}
OK, esta es mi función, que debería devolver una matriz de palabras al filtrar desde$omit
variable. Pero cuando lo uso las palabras en primer$omit
a matriz @ solo se filtra, la segunda se fusionó a partir de la$exclude_list
no está filtrado.
Uso mi función de esta manera:
$filter_array = explode("\n", words list separated by \n new line here);
print_r(processContent('String gere for filtering', $min_word_length, $filter_array));
La variable$filter_array
se pasa a exclude_list también se fusiona para omitir la variable pero no se filtra en el valor de retorno. solo primero$omit
l valor @ se filtra. ¿Hay algo mal en el código?