|
首先分別解釋下,
trim過濾字符串兩端,
rtrim過濾字符串尾部,=chop()
ltrim過濾字符串首部.
過濾字符串中鍵的咚咚就只能用str_replace咯.
舉個(gè)例子說明下,
php代碼
復(fù)制代碼 代碼如下:
$str = '123,333,234,';
echo rtrim($str, ',');
rtrim實(shí)例代碼2
復(fù)制代碼 代碼如下:
<?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技術(shù):PHP字符過濾函數(shù)去除字符串最后一個(gè)逗號(rtrim),轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。