Jump to content

Str Replace despite capitalization


zfred09

Recommended Posts

Try this:

 

$newtext = preg_replace("|$searchterm|i", "<FONT style=\"BACKGROUND-COLOR: yellow\">$searchterm</FONT>", "$text");

 

Changes are:

 

1.  str_replace => preg_replace

2.  "$searchterm" => "|$searchterm|i"

 

The "i" means "case-insensitive", which is the change you wanted to make.  If I had written "|$searchterm|", it would act exactly like str_replace.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.