Page 1 of 1

WildCard for str_replace

Posted: Sun May 16, 2010 6:37 pm
by albertpr9
Hi,

I've got a string that is 8-9 for example, and I'd like to convert it to 8'9, so I'll use

Code: Select all

str_replace("-", "'", $string);
the problem is sometimes the first number comes up as a negative, so it will show -8-7 and if I use the same code above, I'll end up with '8'7, which just won't make any sense.

So my question is, since the "-" sign that I'd like to change would only appear between two other numbers, what wild card can I use to make the code functional...

for example if "*" was a wild card I could just use

Code: Select all

str_replace("*-*", "'", $string);
So the real question I guess is what wild card can I use with str_replace to make this work.

Cheers, and thanks in advance for the help

Re: WildCard for str_replace

Posted: Sun May 16, 2010 7:15 pm
by Weirdan