String replacement in PHP
Posted
by [email protected]
on Stack Overflow
See other posts from Stack Overflow
or by [email protected]
Published on 2010-04-28T06:10:39Z
Indexed on
2010/04/28
6:13 UTC
Read the original article
Hit count: 395
This is my first question on this wonderful website.
Lets say I have a string $a="some text..%PROD% more text"
There will be just one %..%
in the string. I need to replace PROD between the % with another variable content. So I used to do:
$a = str_replace('%PROD%',$var,$a);
but now the PROD between % started coming in different cases. So I could expect prod or Prod. So I made the entire string uppercase before doing replacement. But the side effect is that other letters in the original string also became uppercase. Someone suggested me to use regular expression. But how ?
Thanks, Rohan
© Stack Overflow or respective owner