标签: php arrays formatting
数组转换
$array1 = array(1,2,3,4,5,6,7,8,9,10);
in formate like
$arry2 = array([1],[2,3],[4,5,6],[7,8,9,10]);
答案 0 :(得分:7)
使用array_splice从而将数组中的项目作为增加长度的数组
$i = 1; $arry2 = []; while ($t = array_splice($array1, 0, $i++)) $arry2[] = $t;