470,833 Members | 1,391 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

str_ireplace

Does anyone know of a function that works like str_ireplace in PHP < 5?

str_ireplace(a,b,c) replaces a with b in c, just like str_replace, but case
insensitive.

TIA

- Nicolaas
Oct 24 '05 #1
2 1497
Nicolaas,
Does anyone know of a function that works like str_ireplace in PHP < 5?
mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [,
int limit [, int &count]] )

then just run it with a flag of i. so take your example:

preg_replace('/b/i', 'a', 'c')

a better example of this would be:
$subject = 'this is my MOM';
$pattern = '/mom/i';
$replace = 'DAD';
echo preg_replace($pattern, $replace, $subject);

str_ireplace(a,b,c) replaces a with b in c, just like str_replace, but case
insensitive.

--
Mike Willbanks
Zend Certified Engineer
http://www.digitalstruct.com
Oct 24 '05 #2
Hi why don't you just do the following to get the same result?

$var = strtolower$var); //convert string to lower case
str_ireplace(..., $var);

if you don't want to convert the original string just do

$var = 'SomE STrinG';

$testvar = strtolower($var);
$str_ireplace(..., $testvar);

Tobierre

"windandwaves" <wi*********@coldmail.com> wrote in message
news:H8*******************@news.xtra.co.nz...
Does anyone know of a function that works like str_ireplace in PHP < 5?

str_ireplace(a,b,c) replaces a with b in c, just like str_replace, but
case insensitive.

TIA

- Nicolaas

Oct 25 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by -= Patrick =- | last post: by
6 posts views Thread by Jimmy Clay | last post: by
8 posts views Thread by Simon | last post: by
4 posts views Thread by Chris Jones | last post: by
11 posts views Thread by Fabri | last post: by
omerbutt
23 posts views Thread by omerbutt | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.