Delete last character of string (if exists)
<p>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?</p>

<p>Is this the "correct" way?</p>

<pre><code>if(substr($str, -1) == "/") $str = rtrim($str, '/');
</code></pre>
