1 - single words example - ideone
Computing the difference of the two arrays with the function array_udiff
and without differentiating between upper and lower case with strcasecmp
$bad_words = array('foram','prOcuRar','.....');
$title = "Eles foram com NGTHM4R3 procurar alguma coisa para remover ocorrências de palavras";
$title = implode(" ", array_udiff(explode(" ", $title), $bad_words, 'strcasecmp'));
print_r($title);
2 - Sequence of words example - ideone
$bad_words = array('foram','prOcuRar alguma coisa','alguma','Ponte que partiu');
$title = "Eles foram com NGTHM4R3 procurar alguma coisa pedir ajuda para remover palavras ou sequência de palavras tal como Ponte que partiu";
$title = str_ireplace($bad_words,'',$title);
$title= preg_replace('/\s(?=\s)/', '', $title);
echo $title;
DOCS:
array_udiff
strcasecmp
str_ireplace
Leo, an observation, if the word $bad_words are composed, would not make identification because of the explode. Example, if 'search' was 'looking for some'.
– Bruno Rigolon
@Bruno Rigolon, this is not clear in the question, as it was asked, it is meant to be isolated words. But I will take advantage and edit the answer.
– user60252
I agree Leo, it was just an observation. ;)
– Bruno Rigolon
@Bruno Rigolon of which way was worth because I developed another option :)
– user60252