On Sun, 2008-10-26 at 10:18 +0200, Stan Vassilev | FM wrote: > > My question is this, for just two words its fine to use the above, but a > > pal tells me that if using a lot of words (eg: 15) and the $comment is big > > then it can take quite some time and be a bit of a processing strain as > > well because php first checks the first word from the good list against > > all the 15 words in the bad list against the comment then moves to the > > second word etc. > > > > You should do the filtering on save, not on display, this way the processing > time will drop by order of few magnitudes in comparison. > > Always save the original post content as well, in case you want to tweak the > filter and reprocess the messages. > > Regards, Stan Vassilev > > What you really need to watch out for is words which you're going to censor which might be part of other names. Sex is an obvious one, as it appeared in the borough name of my old address: Middlesex. Instead of using str_replace, what about using preg_replace, which gives you a bit more control over the words that you are replacing, for example, only words on their own, etc. This will also let you get around deliberate mis-spellings of a profanity, such as 'fcuk', by using an expression like "/f[uc]k/iw" Obviously, this list could get pretty comprehensive, so like Andrew said, maybe you should look to see how some of the open source projects do it. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php