tags:

views:

574

answers:

2

i have some urls

www.amazon.com/
www.digg.com
www.microsoft.com/

etc. i want to remove the trailing slash. so not just the last character. is there a trim or rtrim for this? or something fast?

+9  A: 

You put rtrim in your answer, why not just look it up?

$url = rtrim($url,"/");

As a side note, look up any PHP function by doing the following:

Erik
stackoverflow is so much faster :-D
daniel
Give a man a fire and he's warm for a day, set a man on fire and he's warm for the rest of his life. You get my point. The php.net website is one of the language's killer features -- use it.
Erik
@daniel: SO isn't your personal search engine, though. Avoiding *any* effort in answering your question yourself is generally not well received ...
Joey
A: 
$urls="www.amazon.com/ www.digg.com/ www.microsoft.com/";
echo preg_replace("/\b\//","",$urls);
No, don't use regex for this.
Richard Knop
Besides, the RE would fail pretty nicely for URLs that also contain slashes in the middle.
Joey