$swearies = array('sod', 'bleeding', 'blimey', 'cripes');
$replace = '&%@#$';
$string = 'Blimey! The sod clear took orf my bleeding ears!';
$string = preg_replace('#('.join('|', $swearies).'#i', $replace, $string);
Erm, str_replace will do that just as well for a fraction of the CPU usage.robmiller said:Surely you can think them up yourself?
Code:$swearies = array('sod', 'bleeding', 'blimey', 'cripes'); $replace = '&%@#$'; $string = 'Blimey! The sod clear took orf my bleeding ears!'; $string = preg_replace('#('.join('|', $swearies).'#i', $replace, $string);
Conrad11 said:One that will filter the common ways of getting around the filters aswell.
Conrad11 said:I wanted an already made script that is known to stop most of the ways people get around it, like putting spaces, putting dots, putting commas....the list goes on.
Thanks....
[edit]
I am still reading through the preg-replace thing on php.net so if what you put does what i've asked, then sorry, and thanks....
Or str_ireplace()Moredhel said:Erm, str_replace will do that just as well for a fraction of the CPU usage.
$string = str_replace($swearies, $replace, $string);
That's why God invented the banhammer. You see it in action here - you can't efficiently filter swear words and all their typo forms automatically (as you get more complex, the user gets more complex in their attempts to mask, so it's a vicious circle), which is why there's moderators.I wanted an already made script that is known to stop most of the ways people get around it, like putting spaces, putting dots, putting commas....the list goes on.
Moredhel said:Erm, str_replace will do that just as well for a fraction of the CPU usage.