How to remove the comma on the right in php

藏色散人
Release: 2023-03-09 21:42:01
Original
1793 people have browsed it

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.

How to remove the comma on the right in php

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, ',');
Copy after login

rtrim example code 2

The code is as follows:

Copy after login

[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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!