Home  >  Article  >  Backend Development  >  php split Chinese characters_PHP tutorial

php split Chinese characters_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:45:591078browse

First method:
Load the Encode module, provided you need to install this module
Example code:

Copy code The code is as follows:

$str=decode("gb2312",$names[$index]);
@chars=split(//,$str);
foreach(@chars)
{
$char=encode("gb2312",$_);
print "ONE WORD:$charn";
}

The second method:
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];

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320260.htmlTechArticleThe first method: Load the Encode module, provided that you need to install this module. Example code: Copy the code as follows: $str=decode("gb2312",$names[$index]); @chars=split(//,$str)...
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