The rtrim()
function trims whitespace from the righthand side of a string.
PHP rtrim() Function has the following syntax.
string rtrim ( string str [, string trim_chars] )
The optional second parameter to trim() sets the individual characters you want it to trim.
PHP rtrim() Function returns the right trimmed string.
trim a string from right
<?PHP
$string = rtrim(" java2s.com ");
print ">"+$string+"<";
?>
The code above generates the following result.