php去除右邊的逗號的方法:先建立一個PHP範例檔案;然後透過「rtrim($str, ',');」方法刪除字串中右邊的逗號即可。
本文操作環境:Windows7系統、PHP7.1版,DELL G3電腦
先分別解釋下,
trim過濾字串兩端,
rtrim過濾字串尾部,=chop()
ltrim過濾字串首部.
過濾字串中鍵的咚咚就只能用str_replace咯.
舉例說明下,
PHP程式碼
程式碼如下:
$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中文網其他相關文章!