I have the following string:
"This is my string with three instances of MYTEXT. That was the first instance. This is the second instance of Mytext. And this is the third instance of mytext."
I need to replace each instance of Mytext (all three instances) with a version wrapped in a tag, so I want to wrap HTML tags around each instance. This is easy enough and I have no problem doing this. My question is - how do I do this while retaining the original case of each instance. The output I need is:
"This is my string with three instances of MYTEXT. That was the first instance. This is the second instance of Mytext. And this is the third instance of mytext."
I've been looking at str_ireplace and preg_teplace but none of them seem to do the job.
Any ideas?
Thanks in advance.