Code for using split to separate Chinese characters in PHP
WBOYOriginal
2016-07-25 09:03:531037browse
$str=decode("gb2312",$names[$index]);
@chars=split(//,$str);
foreach(@chars)
{
$ char=encode("gb2312",$_);
print "ONE WORD:$charn";
}
Copy code
Method 2:
Chinese characters occupy 2 bytes, so you can use the following statement to directly get the Chinese characters. The code is as follows:
@chars=split(//,$names[$index]);
$str=$chars[0].$chars[1];
Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn