Is there a way to make preg_replace case insensitive?
I am working on a profanity filter and so far have the following:
$input=strtolower ($input);
$pattern = array ("/butt/","/poop/"
;
$replace = array ("rear","feces"
;
$output=preg_replace($pattern, $replace, $input);
I must drop the input to lower case so that 'Butt' or 'BUTT' is properly replaced.
The problem is that the entire string gets dropped to lower case: (Example: 'You are a BUTT!!!' becomes 'you are a butt!!!'). I would like to keep the safe words unchanged. Does anyone have an idea of how to pull this off?
Better yet... Can anyone point me to a good snippet for a profanity filter?
I am working on a profanity filter and so far have the following:
$input=strtolower ($input);
$pattern = array ("/butt/","/poop/"
$replace = array ("rear","feces"
$output=preg_replace($pattern, $replace, $input);
I must drop the input to lower case so that 'Butt' or 'BUTT' is properly replaced.
The problem is that the entire string gets dropped to lower case: (Example: 'You are a BUTT!!!' becomes 'you are a butt!!!'). I would like to keep the safe words unchanged. Does anyone have an idea of how to pull this off?
Better yet... Can anyone point me to a good snippet for a profanity filter?