php逐个汉字遍历字符串 - 在线代码运行


            
执行结果

名称:php逐个汉字遍历字符串

当前代码

<?php
//php逐个汉字遍历字符串
function mbStringToArray ($string) {
    $strlen = mb_strlen($string);
    while ($strlen) {
        $array[] = mb_substr($string,0,1,"utf8");
        $string = mb_substr($string,1,$strlen,"utf8");
        $strlen = mb_strlen($string);
    }
    return $array;
}
print_r(mbStringToArray('我,的电,脑COM'));