$str = preg_replace('/^[\s\x00]+|[\s\x00]+$/u', '', $str);
不能用:
$str = trim($str, chr(0xC2).chr(0xA0))
原因:This solution is not multibyte-safe, it will break encoding of your UTF8 strings
参考:https://stackoverflow.com/questions/18194042/delete-spaces-php