php控制字符串每隔多少个字符加个换行

 public static function chunkSplit($string, $length, $end, $once = false){
//$string = iconv('gb2312', 'utf-8//ignore', $string);
        $array = array();
        $strlen = mb_strlen($string);
        while($strlen){
            $array[] = mb_substr($string, 0, $length, "utf-8");
            if($once)
                return $array[0] . $end;
            $string = mb_substr($string, $length, $strlen, "utf-8");
            $strlen = mb_strlen($string);
        }
        return implode($end, $array);
    }

你可能感兴趣的:(php)