编程爱好者之家
function mbStrSplit ($string, $len=1) { $start = 0; $strlen = mb_strlen($string); while ($strlen) { $array[] = mb_substr($string,$start,$len,"utf8"); $string = mb_substr($string, $len, $strlen,"utf8"); $strlen = mb_strlen($string); } return $array; }
例子如下:
$str = "编程好者之家欢迎您"; print_r(mbStrSplit($str,2)); //返回结果如下 Array ( [0] => 编程 [1] => 好者 [2] => 之家 [3] => 欢迎 [4] => 您 ) print_r(mbStrSplit($str,1)); //返回结果如下 Array ( [0] => 编 [1] => 程 [2] => 好 [3] => 者 [4] => 之 [5] => 家 [6] => 欢 [7] => 迎 [8] => 您 )