PDA

View Full Version : Filter out bad words



Rockonmetal
10-03-2007, 10:53 PM
Hey guys I was if it is possible to filter out words before they are posted on the site. It is two bad that the only way I know how to do this is if the user only enters the bad word... I was thinking of using if else statements, but that doesn't work so well.
I don't know how you can filter out words from a textarea after the form has been submitted... But if you guys wanna see the code I'll post it up...

djr33
10-03-2007, 11:14 PM
$bad = array('monkeys','fish','potatoes');
foreach($bad as $w) {
$string = str_replace($w,'',$string);
}

Rockonmetal
10-03-2007, 11:22 PM
hold on a bit and I'll put the code in... and test it... and reply with the results...

tech_support
10-04-2007, 05:53 AM
$bad = array('monkeys','fish','potatoes');
foreach($bad as $w) {
$string = str_replace($w,'',$string);
}
You might want to replace it with something like #@#%%!!, or else it won't make any sense.

djr33
10-04-2007, 06:19 AM
It's fun to replace it with weird things.

Like... 'gagagoogoo!'