Maison  >  Article  >  développement back-end  >  php split汉字_PHP教程

php split汉字_PHP教程

WBOY
WBOYoriginal
2016-07-21 15:45:591078parcourir

第一种办法:
加载 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];

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/320260.htmlTechArticle第一种办法: 加载 Encode模块,前提是你需要安装这个模块 例子代码: 复制代码 代码如下: $str=decode("gb2312",$names[$index]); @chars=split(//,$str)...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn