php如何去掉字符串最后一个字符

WBOY
Release: 2016-06-23 13:49:38
Original
1334 people have browsed it

php如何去掉字符串最后一个字符,$a = 1,2,3,4,      ,注意,是去掉4后面的逗号,而不是去掉4


回复讨论(解决方案)

trim($string, ',');

echo substr($a, 0, -1);

$a='1,2,3,4,';$b=rtrim($a,',');echo $b;
Copy after login

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template