How to remove trailing slash from URL with PHP

Posted 2 years ago

To remove a character from the end of a string (in this case a URL) rtrim is the answer, which stands for “Right Trim”.

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

You can read up on rtrim on the PHP manual - http://php.net/rtrim