string rtrim ( string $str
[, string $charlist
] )
这个函数很好理解、r表示右边、trim表示修剪、即右边修剪、默认修剪字符str右边的字符。默认修剪空格字符。
而当指定$charlist时、其修剪方法是一个个字符的匹配。
先从$charlist取第一个字符和$str最后一个匹配、如果匹配则删除$str后面那个字符。
不匹配则接着匹配$charlist的下个字符直到、$charlist被扫描一篇且没有匹配则完成右裁剪。
如果有匹配的则从$charlist的头开始重新和新的$str的尾字符一个个匹配。
例子:
<?php
// Example 1:
rtrim('This is a short short sentence', 'short sentence');
// returns 'This is a'
// If you were expecting the result to be 'This is a short ',
// then you're wrong; the exact string, 'short sentence',
// isn't matched. Remember, character-by-character comparison!
// Example 2:
rtrim('This is a short short sentence', 'cents');
// returns 'This is a short short '
?>
2013 09 11
By ACReaper