Remove item from array if it exists in a ‘disallowed words’ array

You want array_diff.

array_diff returns an array containing
all the entries from array1 that are
not present in any of the other
arrays.

So you want something like:

$good = array_diff($arr, $disallowed_words);

Leave a Comment