You are here: Re: PREG_MATCH and arrays « PHP Programming Language « IT news, forums, messages
Re: PREG_MATCH and arrays

Posted by Rik Wasmus on 01/02/08 22:04

On Wed, 02 Jan 2008 23:00:05 +0100, Michael Fesser <netizen@gmx.de> wrot=
e:

> .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 proc=
ess
>> now.
>
> You could concatenate all your keywords with an '|', which will be see=
n
> as a logical OR in the pattern. Then just drop the inner loop:
>
> $filter_test =3D array("Thundarr the Barbarian", ...);
> $filter_title =3D array("Thundarr", "Cash", "Kotter");
>
> $keywords =3D 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 thoug=
h.
-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация