With this simple php script you can remove any specified words from a string. This is very useful when you need to filter input to strip forbidden words.
Example
//strip specific words
$string = 'Nice useful handy bad ugly great';
$wordlist = array("bad", "ugly");
foreach ($wordlist as &$word) {
$word = '/\b' . preg_quote($word, '/') . '\b/';
}
$string = preg_replace($wordlist, '', $string);