I have an obsessive love for php's array functions given how extremely easy they've made complex string handling for me in various situations... so, have another string-rtrim() variant:
<?php
function strrtrim($message, $strip) {
$lines = explode($strip, $message);
$last = '';
do {
$last = array_pop($lines);
} while (empty($last) && (count($lines)));
return implode($strip, array_merge($lines, array($last)));
}
?>
Astonishingly, something I didn't expect, but: It completely compares to harmor's rstrtrim below, execution time wise. o_o Whee!