Php step: insert other characters between N characters

Source: Internet
Author: User
Php method: insert other characters between N characters. recently, the excel downloading function is provided. to solve the problem, you can only manually adjust the branch width of each column, so I wrote an automatic line feed method functionmbstringtoarray ($ str, $ cut_len, $ charset, $ inter = & quot; & lt; br/& gt; php method: how to insert other characters between N characters

Recently, an excel file downloading function was developed. to solve the problem of each column width, you can only manually adjust the branch. Therefore, an automatic line feed method was provided.

Function mbstringtoarray ($ str, $ cut_len, $ charset, $ inter ="
") {$ Strlen = mb_strlen ($ str, $ charset); $ array = array (); while ($ strlen) {$ array [] = mb_substr ($ str, 0, $ cut_len, $ charset); $ str = mb_substr ($ str, $ cut_len, $ strlen-$ cut_len, $ charset); $ strlen = mb_strlen ($ str, $ charset);} return implode ($ inter, $ array );}

It's not bad to use. haha, this solves the problem of Chinese character garbled characters.


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.