The following code can be used to not display php array results that contain certain “blacklisted” words.
$a = array("orange", "purple", "red", "blue"); $clean = Array(); $blacklist = '/(oranges|red)/'; foreach($a as $b) { if(!preg_match($blacklist, $b)) { $clean[] = $b; } }