PHP字符過濾函數去除字符串最后一個逗號(rtrim)
更新時間:2013年03月26日 22:59:08 作者:
PHP字符過濾函數去除字符串最后一個逗號,用php自帶的函數比較容易解決
首先分別解釋下,
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)
?>
您可能感興趣的文章: