Split Chinese strings into arrays to solve str_split Chinese garbled php

Source: Internet
Author: User
Split Chinese strings into arrays to solve str_split Chinese garbled characters. php first introduces str_split;

It separates strings into arrays;

For example:

$ Str = 'ABCDE'; str_plite ($ str); the output is as follows: array ([0] => a [1] => B [2] => c [3] => d [4] => e)

It looks quite easy to use, but as a Chinese programmer, it is inevitable to deal with Chinese;

At this time, str_splite will be used to find out the garbled characters ;;;

Do not be afraid; preg_splite can save this problem;

Of course, it must be used with regular expressions;

/*** Split the string into an array * @ param string $ str string * @ return array the split array */function mb_str_split ($ str) {return preg_split ('/(?

 White [1] => Jun [2] => Yao [3] => Bo [4] => Ke)

Finishing; finishing;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.