PHP Tutorials Match regular expressions for Chinese characters
Matching regular expressions for Chinese characters: [U4E00-U9FA5]
Commentary: Matching Chinese is really a headache, with this expression will be easy to do
Match Double-byte characters (including Chinese characters): [^x00-xff]
Commentary: can be used to compute the length of a string (a double-byte character length meter 2,ascii 1 characters)
*/
$STR = "Singlepoint single point Log";
if (Preg_match ("/^[x{4e00}-x{9fa5}]+$/u", $str)) {
Print ("The string is all Chinese");
} else {
Print ("This string is not all Chinese");
}
$alias _len = Mb_strlen ($value [' Alias '], "utf-8");
$temp _array = Array ();
for ($i = 0; $i < $alias _len; $i + +)
{
$temp _array[$i] = mb_substr ($value [' Alias '], $i, 1, "utf-8");
if (Ord (substr ($temp _array[$i],0,1)) > ' 0xe0 ' && strlen ($temp _array[$i]) <3)
$temp _array[$i] = ';
}
$value [' alias '] = Implode (', $temp _array);