php去掉字串最後一個逗號的方法:使用函數rtrim過濾字串尾部,程式碼為【$trimmed = "\t\tThese are a few words :) .."$str = '13, 3';echo rtrim($str, ',')】。
【相關學習推薦:#php圖文教學##】
php去掉字串最後一個逗號的方法:
首先分別解釋下,str_replace咯.
$str = '123,333,234,'; echo rtrim($str, ','); rtrim实例代码2程式碼如下:
<?php $text = "\t\tThese are a few words :) ... "; $trimmed = rtrim($text); // $trimmed = "\t\tThese are a few words :) ..." $trimmed = rtrim($text, " \t."); // $trimmed = "\t\tThese are a few words :)" $clean = rtrim($binary, "\x00..\x1F"); // trim the ASCII control characters at the end of $binary // (from 0 to 31 inclusive) ?>
相關學習推薦:php程式設計(影片)
#
以上是php如何去掉字串最後一個逗號的詳細內容。更多資訊請關注PHP中文網其他相關文章!