On 17/05/06, René Fournier <m5@xxxxxxxxxxxxxxxx> wrote:
Looking for suggestions on the most compute-efficient way to search variable-length strings (~200 characters) for the occurrence of one of about 100 possible needles. In other words:
$needles = array ( 1 => "Hello Jim" , 2 => "Yellow Banana" , 3 => "Red Car", ... etc .... (100 elements) $haystack = "Once upon a time there was a programming language that everyone loved. Its name was PHP, and the people that worked with it also liked Yellow Bananas. One day...";
What version of php? If you're using php5 then you could do: <?php $count = 0; str_replace($needles, '', $haystack, $count); if ($count) { /* there was a match */ } ?> -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php