我现在使用的方法是:for($i =0 ; $i
请问应该如何提高效率?是否可以讲$str转换为数组?
回复内容: 我有个字符串,格式为$str = 中华人民abc共和\x01国,如何逐个汉字遍历该字符串呢?即:能够输出“中” “华” “人” “民” “a” ...
我现在使用的方法是:for($i =0 ; $i
请问应该如何提高效率?是否可以讲$str转换为数组?
function str_split_unicode($str, $l = 0) {if ($l > 0) {$ret = array();$len = mb_strlen($str, utf-8);for ($i = 0; $i 中 [1] => 华 [2] => 人 [3] => 民 [4] => a [5] => b [6] => c [7] => 共 [8] => 和 [9] => \ [10] => x [11] => 0 [12] => 1 [13] => 国)
//utf8算法,其它编码自行转换
$cind = 0; $arr_cont = array(); for ($i = 0; $i 0) { if (ord(substr($tempaddtext, $cind, 1))