|
Posted by Poster on 01/02/08 22:15
"Rik Wasmus" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.t4boxkyc5bnjuv@metallium.lan...
On Wed, 02 Jan 2008 23:00:05 +0100, Michael Fesser <netizen@gmx.de> wrote:
> .oO(Poster)
>
>> "Rik Wasmus" <luiheidsgoeroe@hotmail.com> wrote in message
>> news:op.t4bm9bgf5bnjuv@metallium.lan...
>>
>>> Keep in mind the inner most foreach will be run entirely before the
>>> second
>>> entry of the outer foreach.
>>
>> Thanks, I didn't realize that. I'll have to rethink the checking process
>> now.
>
> You could concatenate all your keywords with an '|', which will be seen
> as a logical OR in the pattern. Then just drop the inner loop:
>
> $filter_test = array("Thundarr the Barbarian", ...);
> $filter_title = array("Thundarr", "Cash", "Kotter");
>
> $keywords = implode('|', $filter_title);
>
> foreach ($filter_test as $title) {
> if (preg_match("/\b$keywords\b/i", $title)) {
> // match
> } else {
> // no match
> }
> }
>
> Or something like that.
One could do that, I'd advise top use a preg_quote() on the values though.
--
Rik Wasmus
Thanks for your posts too - I'll look on the PHP site about the preg_quote.
There are so many functions to check out. Thanks for your help.
Navigation:
[Reply to this message]
|