Hi All,
The subject is probably not as clear as it could be, but I was struggling to think of a better way to easily describe it.
I am implementing a badword filter on some articles that we pick up from an XML feed. At the moment I have the badwords in an array and simply check the text like so;
str_replace($badwords, '', $text, $count);
if ($count > 0) // We have bad words...
But this is SLOW! So slow! And when I am trying to process 30,000+ articles at a time, I start wondering if there is a better way to achieve this. If only strpos supported arrays! Even then I dont think it'd be faster...
I'd love any suggestions. Thanks in advance!
EDIT:
I have now tested a few methods between calls to microtime() to time them. str_replace() = 990 seconds preg_match() = 1029 seconds (Remember I only need to identify them, not replace them) no bad word filtering = 1057 seconds (presumably because it has another thousand or so bad-worded articles to process.
Thanks for all the answers, I will just still with str_replace. :)