$text = \t\tthese are a few words :) ... ;
var_dump($text);
echo '----------------------------------';
echo '
';
$trimmed = trim($text);
var_dump($trimmed);
$trimmed = trim($text, \t:));
var_dump($trimmed);
输出:
string 'these are a few words :) ...' (length=28)
string 'these are a few words :) ...' (length=28)
$trimmed = trim($text, \t:).);
var_dump($trimmed);
输出:
string 'these are a few words' (length=21)
疑问是::)加了一个.后就能正常过滤了。为毛?
回复讨论(解决方案) trim 的第二个参数是一个字符列表
凡是出现在该列表中的,第一个参数两端的字符都会被删去。在第一个不在列表中的字符处停止