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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -