Home > Backend Development > PHP Tutorial > php split Chinese characters_PHP tutorial

php split Chinese characters_PHP tutorial

WBOY
Release: 2016-07-21 15:45:59
Original
1137 people have browsed it

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)...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template