You could do:
$string = substr(trim($string), 0, -1);
And get the same effect. It seems like you also want to make sure it is a specific character, so it would be easier to just keep what you have.. or
function removelastchar($string, $chr) {
if (substr(trim($string), 0, -1) == $chr)
$string = substr(trim($string), 0, -1);
return $string;
}
easy enough? Just a little more readable. Hope that helps ??
Chris King