Re: Swear filter ideas
- From: ZeldorBlat <zeldorblat@xxxxxxxxx>
- Date: Wed, 27 Jun 2007 16:11:17 -0700
On Jun 27, 6:18 pm, r...@xxxxxxxxxxxxx (Richard Davey) wrote:
Hi all,
Just wanting to pick your collective brains on this one:
How do you go about implementing a swear / bad-word filter in PHP?
Reasons for needing one aside, I'm just wondering if you favour a
regexp, a substr_count, or what? Do you like to *** out the bad words,
or just error back to the user? (I guess that is application
specific).
There are always ways to circumvent them, but I'm still curious to
know how you prefer to handle it.
Cheers,
Rich
--
Zend Certified Engineerhttp://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"
Why not just use str_replace() with a list of words?
$bad_words = array('foo', 'bar', 'baz');
$dirty_sting = 'Go foo yourself you baring baz!';
$clean_string = str_replace($bad_words, '****', $dirty_string);
.
- References:
- Swear filter ideas
- From: Richard Davey
- Swear filter ideas
- Prev by Date: Swear filter ideas
- Next by Date: strange include path error
- Previous by thread: Swear filter ideas
- Next by thread: Re: [PHP] Swear filter ideas
- Index(es):
Relevant Pages
|