选择语言 :

 Core_UTF8::str_split

Converts a UTF-8 string to an array. This is a UTF8-aware version of str_split.

$array = UTF8::str_split($str);

array Core_UTF8::str_split( string $str [, integer $split_length = integer 1 ] )
author
Harry Fuecks hfuecks@gmail.com

参数列表

参数 类型 描述 默认值
$str string Input string
$split_length integer Maximum length of each chunk integer 1
返回值
  • array
File: ./core/classes/utf8.class.php
public static function str_split($str, $split_length = 1)
{
    $split_length = (int)$split_length;

    if ( UTF8::is_ascii($str) ) return str_split($str, $split_length);

    if ( $split_length < 1 ) return FALSE;

    if ( UTF8::strlen($str) <= $split_length ) return array($str);

    preg_match_all('/.{' . $split_length . '}|[^\x00]{1,' . $split_length . '}$/us', $str, $matches);

    return $matches[0];
}