Home > php教程 > php手册 > php方法:N个字符间插入其它字符的方法

php方法:N个字符间插入其它字符的方法

WBOY
Release: 2016-06-13 10:52:12
Original
1137 people have browsed it

最近做一个excel下载功能,为了解决每一列宽度,只能手动调整分行,于是写了一个自动换行的方法
[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); 

用起来还不错,呵呵,这个也解决了中文字符乱码的问题。

source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template