Re: Re: case-insensitive str_replace
| From: | CC Zona | Date: | Thu, 02 May 2002 22:07:39 +0000 |
| Subject: | Re: Re: case-insensitive str_replace | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95778@lists.php.net to get a copy of this message | ||
In article <GVI5RV00.CF8@mail.goshen.edu>,
reubendb@goshen.edu (Reuben D Budiardja) wrote:
> On Thursday 02 May 2002 04:08 pm, J Smith wrote:
> > preg_replace() can be used with arrays.
>
> Yeah, but how to make it case-insensitive beside changing the my search and
> replace strings to a regular expression? The problem is that I have a big
> array for search and replace, and it would be most labourious to change them
> to reg exp.
It shouldn't be laborious, if the array's values were--as you
implied--compatible with str_replace. You're replacing an array of
straight string values, correct? So just escape the regex special values
(preg_quotes()) in each while you're looping through the array to add the
pattern delimiters and "i" modifier. Then pass that array to preg_replace.
--
CC