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, '/');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…