Delete last character of string (if exists)
php
Solution
Use `rtrim` without a condition, it's shorter and probably faster as well. The added `if` is noise and doesn't offer anything.
Problem
I have a string containing some text, the last character might (might) be a slash, which I don't want. How do I remove that, if it exists? Is this the "correct" way? ``` if(substr($str, -1) == "/") $str = rtrim($str, '/'); ```