Home > Backend Development > PHP Tutorial > trim()函数,可选字符串的疑问

trim()函数,可选字符串的疑问

WBOY
Release: 2016-06-23 13:35:16
Original
995 people have browsed it

$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 的第二个参数是一个字符列表
凡是出现在该列表中的,第一个参数两端的字符都会被删去。在第一个不在列表中的字符处停止

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template