Home  >  Article  >  Backend Development  >  Code for using split to separate Chinese characters in PHP

Code for using split to separate Chinese characters in PHP

WBOY
WBOYOriginal
2016-07-25 09:03:531037browse
  1. $str=decode("gb2312",$names[$index]);
  2. @chars=split(//,$str);
  3. foreach(@chars)
  4. {
  5. $ char=encode("gb2312",$_);
  6. print "ONE WORD:$charn";
  7. }
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:

  1. @chars=split(//,$names[$index]);
  2. $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