- rtrim: documentation ( source)
<?php
$text = "This string contains some unwanted characters on the end.";
$text1 = rtrim($text, 'a..z');
$text1 = rtrim($text1, '.');
echo $text1; // only the '.' is trimmed.
echo '<br />';
$text2 = rtrim($text, 'a..z.');
echo $text2; // The whole last word is trimmed.