Home > Article > Backend Development > How to use php rtrim function
php The rtrim() function is used to remove spaces or other predefined characters (if specified) on the right side of the string and return the modified string; the syntax is "rtrim(string,charlist)", parameter string Specify the string to be processed, and the parameter charlist specifies which characters to delete from the string.
How to use the rtrim() function?
Function: Remove spaces or other predefined characters on the right side of the string and return the modified string.
Syntax:
rtrim(string,charlist)
Parameters:
string, the string to be processed.
charlist Optional, specifies which characters to delete from the string, if empty, remove all the following characters "\0" -- NULL, "\t" -- Tab character, "\n" -- line feed, "\x0B" -- vertical tab character, "\r" -- carriage return, " " -- space
Return Value: Returns the modified string.
php rtrim() function usage example:
<?php $i = "hello world "; echo "未经过处理的".$i."右边是有空格的!"; $j = rtrim($i); echo "经过处理的".$j."右边是没有空格的!"; ?>
Output:
未经过处理的hello world 右边是有空格的!经过处理的hello world右边是没有空格的!
The above is the detailed content of How to use php rtrim function. For more information, please follow other related articles on the PHP Chinese website!