巴扎黑2017-04-10 14:53:061楼
//UTF8算法,其它编码自行转换
$cind = 0;
$arr_cont = array();
for ($i = 0; $i < strlen($tempaddtext); $i++) {
if (strlen(substr($tempaddtext, $cind, 1)) > 0) {
if (ord(substr($tempaddtext, $cind, 1)) < 192) { //如果为英文则取1个字节
if (substr($tempaddtext, $cind, 1) != " ") {
array_push($arr_cont, substr($tempaddtext, $cind, 1));
}
$cind++;
} elseif(ord(substr($tempaddtext, $cind, 1)) < 224) {
array_push($arr_cont, substr($tempaddtext, $cind, 2));
$cind+=2;
} else {
array_push($arr_cont, substr($tempaddtext, $cind, 3));
$cind+=3;
}
}
}
print_r($arr_cont);