Home > Backend Development > PHP Tutorial > php split汉字_php技巧

php split汉字_php技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-17 09:32:15
Original
1038 people have browsed it

第一种办法:
加载 Encode模块,前提是你需要安装这个模块
例子代码:

复制代码 代码如下:

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

第二种办法:
中文字符是占了2个字节,所以你可以用下面语句直接得到汉字,代码如下:
@chars=split(//,$names[$index]);
$str=$chars[0].$chars[1];
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template