In PHP, you can use the rtrim function to remove the last character. The syntax for using this function is "rtrim(string,charlist)". The function of this function is to remove the blank characters or other characters on the right side of the string. Predefined characters.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
rtrim() function removes strings Whitespace characters or other predefined characters on the right.
Related functions:
ltrim() - Removes whitespace characters or other predefined characters on the left side of the string
trim() - Removes both sides of the string Blank characters or other predefined characters
Syntax
rtrim(string,charlist)
[Recommended learning: PHP video tutorial]
The above is the detailed content of How to remove the last character in php. For more information, please follow other related articles on the PHP Chinese website!