I've been trying to figure out how to take an array of items and divide it into 4 html lists (that's my specific need but divide by X would be better), with the extra requirement that any remainders be added from the front.
This is different to array_chunk()
which will do the following:
item 1 item 4 item 7 item10
item 2 item 5 item 8
item 3 item 6 item 9
Where in fact what I need is this:
item 1 item 4 item 7 item 9
item 2 item 5 item 8 item 10
item 3 item 6
With array_chunk()
I can get the first output with something like this answer but array_chunk()
takes a number of items per chunk as an argument and just leaves the last chunk shorter than the rest.