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,,,,,
以前の質問に従って implode を使用してみましたが、最後のコンマのみをトリムしています。
最後のコンマを削除するには?
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);