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

Code for using split to separate Chinese characters in PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 09:03:53
Original
1100 people have browsed it
  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


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