$str = 'abcdefgh';
$arr = str_split($str,2);
来个手写版的:
$str = 'abcdefgh';
$arr = str_split($str);
$i = 0;$limit = 3;
$num = count($arr);
while($i <= $num-1){
$temp = array();
$for_countbu = ($num-$i) >= $limit ? $limit : $num - $i;
for($j = 0; $j < $for_countbu; ++$j)
{
$temp[] = $arr[$i];
++$i;
}
$one = implode('',$temp);
$result[] = $one;
}
print_r($result);