去除多余空格 多个连续空格只保留一个

/**
* 多个连续空格只保留一个
*
* @param string $string 待转换的字符串
* @return unknown
*/
static public function merge_spaces ( $string )
{
    return preg_replace ( "/\s(?=\s)/","\\1", $string );
}

猜你喜欢

转载自my.oschina.net/u/1422143/blog/1812217
今日推荐