php method to remove the comma on the right: First create a PHP sample file; then use the "rtrim($str, ',');" method to delete the comma on the right in the string.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
First explain each separately,
trim filters both ends of the string,
rtrim filters the tail of the string, =chop()
ltrim filters the beginning of the string.
Filters the key in the string You can only use str_replace.
As an example,
PHP code
The code is as follows:
$str = '123,333,234,'; echo rtrim($str, ',');
rtrim example code 2
The code is as follows:
[Recommended learning:PHP video tutorial]
The above is the detailed content of How to remove the comma on the right in php. For more information, please follow other related articles on the PHP Chinese website!