From: http://www.cnblogs.com/yhyjy/archive/2012/02/22/2363008.html
原字符串1,2,3,4,5,6,
去掉最后一个字符",",最终结果为1,2,3,4,5,6
代码如下:
- $str = "1,2,3,4,5,6,";
- $newstr = substr($str,0,strlen($str)-1);
- echo $newstr;
- //echo 1,2,3,4,5,6
系统自带的函数即可实现这样的效果,两种方法:
- substr($str, 0, -1)
- //函数2
- rtrim($str, ",")