首先分別解釋下,
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)
?>