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

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

WBOY
WBOYOriginal
2016-06-13 10:52:121142browse

最近做一个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); 

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

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
Previous article:php 插入排序Next article:PHP + Apache Stack vs Node.js