At 21:22 24.02.2003, {R}ichard Ashton spoke out and said:
--------------------[snip]--------------------
>while ( $flag == true )
>if (strpos($body, $word[]) > 0) {$flag=false}
>
>What I really need to know is which is the fastest loop?
>Which is the fastest match, strpos?
>Which is the fastest comparison?
>What other optimisations are possible to maximise search speed?
>
>I would expect to keep a frequency hit count and sort the $words[] so
>that the most frequent hits are found first, remembering that only
>$body with NO $words in then are automatically posted, so every word
>must be tested.
>
>I don't know sufficient internals to pick the fastest method. I will be
>running with 4.3.1 on FreeBSD 4.6
--------------------[snip]--------------------
I'd suggest something like this:
$buzzwords = array('idiot', 'fool', 'shit', 'FOAD');
$re = '/(' . implode('|',$buzzwords).')/is';
if (preg_match($re, $posting))
// bad word found
else
// cleared
You only need to make sure that your buzzwords dont contain a '/' - you
could change the regex delimiter then, or simply escape it in the array.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php