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
Release: 2016-07-13 17:54:08
Original
865 people have browsed it

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 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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template