WildCard for str_replace
Posted: Sun May 16, 2010 6:37 pm
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
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
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
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);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);Cheers, and thanks in advance for the help