I have an array of dynamic length L1. I need to split this array into L2 number of arrays each having LEN[i] numbers from the original array.
Input arrays:
$array = [1,2,3,4,5,6,7,8,9,10]
$LEN = [3,3,4]
$LEN states how many elements each new array should contain. The 3 arrays will be:
$a1 = [1,2,3]
$a2 = [4,5,6]
$a3 = [7,8,9,10]
I have tried a lot of ways but nothing seems to be working. Any help would be greatly appreciated.