Monday, 9 September 2013

Replace all the _ except last one

Replace all the _ except last one

I have the following url:
http://distilleryimage3_s3_amazonaws_com/8af11cdcf11e286b022000ae90285_7_jpg
I want to replace the _ with .. However, the _7 at the end should be kept
- it is not a dot.
So, basically it should look like:
http://distilleryimage3.s3.amazonaws.com/8af11cdcf11e286b022000ae90285_7.jpg
If I use str_replace it will replace all the _ but I need to keep that one
there. How can I do this?

No comments:

Post a Comment