Remove Trailing Slash From String PHP

Is it possible to remove the trailing slash / from a string using PHP?

Answers


Sure it is, simply check if the last character is a slash and then nuke that one.

if(substr($string, -1) == '/') {
    $string = substr($string, 0, -1);
}

Another (probably better) option would be using rtrim() - this one removes all trailing slashes:

$string = rtrim($string, '/');

Need Your Help

Invalidate doesn't hide tabs

excel-vba excel-2007 excel-2010 ribbonx fluent-ribbon

I am trying to push the limits of my understanding of the Fluent Ribbon/RibbonUI system in the Office 2007/2010 framework.

How can I make following animation on iOS

ios animation uipageviewcontroller

I want to make animation on iOS like following links.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.