有没有一种巧妙的方法可以根据长度数组将数组拆分为块?
输入:
$start = range(0, 30);
$length = [3, 7, 2, 12, 6];
期望的输出:
[
[0, 1, 2], // 3
[4, 5, 6, 7, 8, 9, 10], // 7
[11, 12], // 2
[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], // 12
[25, 26, 27, 28, 29, 30], // 6
];