if (substr($url, -1) == "/")
$url = substr($url, strlen($url) - 1);
Basically, if we pass a negative number to the function substr, we get the tail end of the string for that many characters. So, substr($url, -1) will return the last character of that string.
Then, we simply take the string and chop off the last character by telling it to take the url and return the entire string, minus one character. (strlen($url) -1) ..
Hope that helps!
Chris King