Remove characters on the right side of a string:
<?php$str = "Hello World!";echo $str . "<br>";echo rtrim($str,"World!");?>The rtrim() function removes whitespace characters or other predefined characters from the right side of a string.
Related functions:
ltrim() - Removes whitespace or other predefined characters from the left side of a string.
trim() - removes whitespace characters or other predefined characters on the right side of a string.
rtrim( string,charlist )
parameter | describe |
---|---|
string | Required. Specifies the string to check. |
charlist | Optional. Specifies which characters are removed from the string. If this parameter is omitted, all the following characters are removed: " |