[filterBlank] #php技巧
/**
* 去掉字符串中的空格
*
* @param string $content
* @param int $len
* @param string $encode
* @param bool $htmltags
*
* @return string 字符串
*/
public function mbStrReplace($content, $len = 0, $encode = 'utf-8', $htmltags = true) {
$str = trim($content);
if ($htmltags) {
$str = strip_tags($str);
}
$str = preg_replace('/[\n|\r|\t]+/', '', $str);
$str = preg_replace("/(\s|\ \;| |\xc2\xa0)/", '', $str);
//借鉴:http://bbs.phpchina.com/thread-209008-1-1.html
if ($len > 0)
return mb_substr($str, 0, $len, $encode);
else {
return $str;
}
}