Re: Swear filter ideas



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);

.



Relevant Pages

  • Swear filter ideas
    ... 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 ...
    (php.general)
  • Re: [PHP] Swear filter ideas
    ... 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 ... scalable system for accessing system services | ...
    (php.general)
  • Re: Parsing PHP with HTML file extension
    ... than ".php" for various reasons (although even better would be no file ... extension at all in the URLs). ... bookmarks, SEO credit, search engine- and other outside links intact & ... apathetic about whether the underlying bits are html, php, python, perl, ...
    (comp.lang.php)
  • Re: Parsing PHP with HTML file extension
    ... than ".php" for various reasons (although even better would be no file ... extension at all in the URLs). ... Ideally, the URL's wouldn't change, keeping all bookmarks, SEO credit, search engine- and other outside links intact & working. ... apathetic about whether the underlying bits are html, php, python, perl, ...
    (comp.lang.php)
  • Re: Constructor as a "Reset" Button
    ... reasons - to keep tight with the OOP design principles. ... Do you know for sure what PHP does internally when calling it? ... Zombie process, or that resources would be locked that don't need to be, ...
    (comp.lang.php)