Short: New efun split_array()
From: Tubmud
Type: Feature
State: Unclassified
mixed *split_array(mixed *arr,int mod);
splits an array into an array of arrays using mod to determine
how many arrays the result shall contain:
split_array(({ 1,2,3,4,5,6,7,8 }),4)
==> ({ ({ 1,5 }),({ 2,6 }),({ 3,7 }),({ 4,8 }) })
If the number of elements in arr is not dividable by mod, the
_first_ N elements of arr are left away, so that sizeof(arr)-N
is dividable by mod:
split_array(({ 1,2,3,4,5,6,7,8,9,10 }),4)
==> ({ ({ 3,7 }),({ 4,8 }),({ 5,9 }),({ 6,10 }) })
This behaviour is sometimes a problem, sometimes it comes in
quite handy. If it does not fit your task, you could add
allocate(mod-1-(sizeof(arr)-1)%mod) to the array to make its
number of elements be a multiple of mod.