code
<?php
$str = 'one two three';
$arr1 = str_split($str);
$arr2 = str_split($str, 3);
print_r($arr1);
print_r($arr2);
?>
输出结果如下:
code
Array
(
[0] => o
[1] => n
[2] => e
[3] =>
[4] => t
[5] => w
[6] => o
[7] =>
[8] => t
[9] => h
[10] => r
[11] => e
[12] => e
)
Array
(
[0] => one
[1] => tw
[2] => o t
[3] => hre
[4] => e
)