<?PHP
// REF: http://us.php.net/str_split
function str_split_unicode($str, $l = 0)
{
if ($l > 0) {
$ret = array();
$len = mb_strlen($str, "UTF-8");
for ($i = 0; $i < $len; $i += $l) {
$ret[] = mb_substr($str, $i, $l, "UTF-8");
}
return $ret;
}
return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
}
$a = 'ㄕㄨ'; // BPMF ZH_TW UTF8/Unicode character
$aa = str_split_unicode($a);
$aaa = str_split($a);
var_dump($a);
var_dump($aa);
var_dump($aaa);
?>
$ php str_split_utf8.php
string(6) "ㄕㄨ"
array(2) {
[0]=>
string(3) "ㄕ"
[1]=>
string(3) "ㄨ"
}
array(6) {
[0]=>
string(1) "▒"
[1]=>
string(1) "▒"
[2]=>
string(1) "▒"
[3]=>
string(1) "▒"
[4]=>
string(1) "▒"
[5]=>
string(1) "▒"
}