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.