Re: str_replace on words with an array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dotan Cohen wrote:
> Thanks all for the heads up with the str_replace not working with
> regexes. Duh! I've switched to preg_replace, but still no luck. (nor
> skill, on my part)
> 
> I'm trying to use array_walk to go through the array and deliminate
> each item with /b so that the preg_replace function will know to only
> operate on whole words, but I just can't seem to get it. I am of
> course Ring TFM and Sing THW but with no luck. A push (link to TFA or
> tutorial, whatever) would be most appreciated.

IMHO, unless you're going to be doing a lot with each element of the
array it's easier to do it without using array_walk.

foreach ($arr as $key => $val)
    $arr[$key] = "\\b".$val."\\b";

-Stut

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux