On the recurring subject of string-stripping instead of character-stripping rtrim() implementations... the simplest (with a caveat) is probably the basename() function. It has a second parameter that functions as a right-trim using whole strings:
<?php
echo basename('MooFoo', 'Foo');
?>
...outputs 'Moo'.
Since it also strips anything that looks like a directory, it's not quite identical with hacking a string off the end:
<?php
echo basename('Zoo/MooFoo', 'Foo');
?>
...still outputs 'Moo'.
But sometimes it gets the job done.