php mb_internal_encoding UTF-8 function mbStringToArray string array a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
mb_internal_encoding("UTF-8");
function mbStringToArray ($string) {
$array = array();
$strlen = mb_strlen($string);
while ($strlen) {
$array[] = mb_substr($string, 0, 1);
$string = mb_substr($string, 1, $strlen);
$strlen = mb_strlen($string);
}
return $array;
}
$str = 'проверка';
header("Content-type:text/html;charset=UTF-8");
echo '<pre>';
var_dump(mb_substr($str, 1, 1));
var_dump(mbStringToArray($str));
echo '</pre>';
?>