Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
示例输出
1. test,test,test,test,test, 2. test,test,test,, 3. test,test,,, 4. test,,,,,
我根据我之前的问题尝试使用内爆,但它只修剪最后一个逗号。
如何删除任何最后的逗号?
rtrim('test,,,,,', ',');
请参阅手册。
rtrim例如:
$str = 'foo,bar,blah,bleh,'; echo rtrim($str,','); // foo,bar,blah,bleh
完全不同的方式:
$str = "1,2,3,4,"; $str = substr($str,0,strlen($str)-1);