English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String String Functions Manual
The rtrim() function is used to remove whitespace characters (or other characters) from the end of the string
string rtrim ( string $str [, string $character_mask ] )
Used to remove trailing spaces from the string
Related Functions:
ltrim() - Remove whitespace characters or other predefined characters from the beginning of the string.
trim() - Remove whitespace characters or other predefined characters from both sides of the string.
It returns the modified string
Number | Parameter and Description |
---|---|
1 | string Input String |
2 | character_mask Specify which characters to remove from the string. If the parameter is omitted, the following characters will be removed by default:
|
Try the following examples, remove trailing spaces and remove the specified string from the end of the string:
<?php $input = "hi sai "; //Remove trailing spaces from the string echo rtrim($input) . "<br>"; //Remove the specified string 'sai' from the end of the string echo rtrim($input,"sai"); ?>Test and see‹/›
Output Result
hi sai hi