General way of trimming last character of string in php is using substr function. So if we want to trim last character say '/' from string "webdevelopmentscripts.com/", Simple way is use to substr() like this:
$trimmed=substr('webdevelopmentscripts.com/',0,strlen('webdevelopmentscripts.com/')-1);

There is another way to do the same, the trick is using rtrim function. Generally we use rtrim function to trim any extra spaces on the right end of the string. But if we supply second parameter to that function, it will strip out that character from string.

Example:
$trimmed=rtrim('webdevelopmentscripts.com/','/');

 


Comments (0)
Leave a Comment

loader Posting your comment...