top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

In PHP how to remove end of slash in url ?

+2 votes
1,155 views

Hi,I have a url some thing like this https://google.com/.I need to replace end of slash in the url.

I need url like this https://google.com.

posted Sep 29, 2014 by Manish Tiwari

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

trim( $str, "/" ); is probably your best/fastest bet.

answer Oct 5, 2014 by Rajneesh
Similar Questions
+2 votes

I want to build a A URL Shortener service in my PHP based Website without use of any thirdparty tool. Any clue or opensource would be a great help?

+1 vote

I'm adding some minification to our cache.class.php and am running into an edge case that is causing me grief.

I want to remove all comments of the // variety, HOWEVER I don't want to remove URLs...

Given some example text here with carefully crafted cases:

// another comment here

function bookmarksite(title,url){
 if (window.sidebar) // firefox
 window.sidebar.addPanel(title, url, "");
 else if(window.opera &
 elem.setAttribute('href',url);
 elem.setAttribute('title',title);
 elem.setAttribute('rel','sidebar');
 elem.click();
 } 
 else if(document.all)// ie
 window.external.AddFavorite(url, title);
}

I've tried so many variations and hunted on StackOverflow, Google, etc. and what would seem like a task already solved, doesn't seem to be.

This is "close", but still matches //foo.com (omitting the : of course)

s*(?!:)//.*?$ (count it as '/m' multiline)

This ultimately ends up in a PHP line of code like so:

$sBlob = preg_replace("@s*//.*?$@m",'',$sBlob);

Here are some other links of stuff I've found and tried to experiment with varying degrees.

http://stackoverflow.com/questions/4568410/match-comments-with-regex-but-not-inside-a-quote
http://stackoverflow.com/questions/611883/regex-how-to-match-everything-except-a-particular-pattern
http://stackoverflow.com/questions/11863847/regex-to-match-urls-but-not-urls-in-hyperlinks
http://stackoverflow.com/questions/643113/regex-to-strip-comments-and-multi-line-comments-and-empty-lines

0 votes

I would like to know how can I pass a parameter via URL using control value on the form.
Something like myPage.php?MyID=txtMyID.value
I can use myPage.php?MyID=1, but cannot use myPage.php?MyID=txtMyID.value.

...