$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, ",")