Home >Backend Development >PHP Tutorial >PHP method: How to insert other characters between N characters_PHP tutorial

PHP method: How to insert other characters between N characters_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:54:08848browse

I recently made an excel download function. In order to solve the width of each column, I could only manually adjust the rows, so I wrote a method for automatic line wrapping
[php
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 pretty good to use, haha, this also solves the problem of garbled Chinese characters.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477975.htmlTechArticleI recently made an excel download function. In order to solve the problem of the width of each column, I could only manually adjust the branches, so I wrote an automatic Line break method [php function mbstringtoarray($str,$cut_len,$cha...
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