PHP中包含四个可以去除字符串空格的函数:
trim() – 去除字符串两端的空字符
ltrim() – 去除字符串前端的空字符
rtrim() – 去除字符串末尾的空字符
chop() –同rtrim().
/**
* PHP中四个去除字符串中空字符的函数
*
* @param
* @arrange 512-笔记网: www.jb51.cc
**/
<?PHP
$text = "\t \t *.com!\t \t ";
$leftTrimmed = ltrim($text);
$rightTrimmed = rtrim($text);
$bothTrimmed = trim($text);
print("leftTrimmed = ($leftTrimmed)\n");
print("rightTrimmed = ($rightTrimmed)\n");
print("bothTrimmed = ($bothTrimmed)\n");
/*** 来自编程之家 jb51.cc(jb51.cc) ***/