$str =' Controllable Eu valence for photoluminescence tuning in apatite-typed';在编码为GBK的情况下是'聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Controllable Eu valence for photoluminescence tuning in apatite-typed';在utf-8下是' Controllable Eu valence for photoluminescence tuning in apatite-typed';
如何去除空格?
Reply content:
$str =' Controllable Eu valence for photoluminescence tuning in apatite-typed';在编码为GBK的情况下是'聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Controllable Eu valence for photoluminescence tuning in apatite-typed';在utf-8下是' Controllable Eu valence for photoluminescence tuning in apatite-typed';
如何去除空格?
Use$str = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',$str);
http://php.net/manual/zh/regexp.reference.unicode.php
Used to match common character types when UTF-8 mode is selected
PC: All Unicode "other"
PZ: All Unicode "separator", all spaces and invisible characters
PHP merges multiple contiguous spaces:
$output = preg_replace('/\s+/', ' ', $input);
\sMatches any whitespace character, including spaces, tabs, page breaks, and so on, equivalent to [ \f\n\r\t\v] .
http://php.net/manual/zh/reference.pcre.pattern.syntax.php
$STR = $str. Replace (/s/g, ");
UrlEncode to see what the character is, (is it a space or something else)