php字符串转数组

下面代码包括了含有中文汉字的字符。

function str2arr($str)
{
    $length = mb_strlen($str, 'utf-8');
    $array = [];
    for ($i=0; $i<$length; $i++)  
        $array[] = mb_substr($str, $i, 1, 'utf-8');    
    return $array;
}

  

 

posted @ 2018-06-12 11:52  scott_j  阅读(464)  评论(0编辑  收藏  举报