Re: is preg_replace the fastest way?
| From: | Scott Hurring | Date: | Tue, 11 Jun 2002 21:17:44 +0000 |
| Subject: | Re: is preg_replace the fastest way? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-101620@lists.php.net to get a copy of this message | ||
I think this is similar to what you're asking for, but it's
probably slower (you have to split(), traverse, then join())
foreach ($noiselist as $noise)
foreach ($inputlist as $input)
if ($noise == $input) // do something
--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Zac Hillier" <zac@affectors.net> wrote in message
news:007f01c2118a$f7a0ba20$667ba8c0@ws...
> Hi All,
>
> I'm writing a search facility and am stripping noise words from a string
> (The string contains between 50 - 200 words). Presently I'm importing a text
> file of noise words (The noise words file contains almost 1000 words) then
> using :
>
> #-- remove noisewords
> $cntLmt = count($noise_words);
> for ($i=0; $i<$cntLmt; $i++) {
> $filterword = trim(strtolower($noise_words[$i]));
> $filtered = preg_replace("/(\b$filterword \b)/x"," ",$filtered);
> }
>
> to remove these noise words.
>
> However I'm wondering if it would be quicker to separate the $filtered
> string and then look for the words in a noise words string. If so how would
> I do this and remove the words?
>
> Thanks
>
> Zac
>