string rtrim( string $text [, string $characterList )
(PHP 4, PHP 5)
| $text | The source string to escape pattern characters. |
|---|---|
| $characterList | A list of characters to be removed. |
| RETURNS | The source string with invalid characters stripped from the end. |
This method takes the source string ($text) and strips any whitespace characters from the end. This whitespace characters are shown below:
| ” ” | Space |
|---|---|
| \t | Tab |
| \n | Line Feed |
| \r | Carriage Return |
| \0 | A null byte |
| \x0B | A vertical tab |
Optionally, you may alsp specify a list of characters you would like to be “trimmed” from the source string by specifying the third parameter $characterList.
// Trim "e", "t" and "y" characters, result is "Not Pr"; $trimmed = rtrim('Not Pretty', 'ety'); echo 'Trimmed Text: ' . $trimmed . '<br>';