Remove Trailing Slash From String PHP -
is possible remove trailing slash /
string using php?
sure is, check if last character slash , nuke one.
if(substr($string, -1) == '/') { $string = substr($string, 0, -1); }
another (probably better) option using rtrim()
- 1 removes all trailing slashes:
$string = rtrim($string, '/');
Comments
Post a Comment