I would need your help with a looping issue, it’s so annoying when the brain just stop functioning.
This is what I want to do:
-
I’ve got an array with some amount of data in it, lets say [6] in this case
-
From the length of this array I create a certain amount of divs. Each div will hold a maximum of 5 array values. So number of divs that will be created = round(sizeof array/5), so 2 divs in this case.
So far so good, but now to the part I can’t figure out. How do I create the loop that prints out index 0-4 in div 1 and then goes forward and creates a second div to print out index 5-6 in.
And of course it should all be dynamically so if I’ve got 20 values in the array it will create and fill 4 divs with the values.
Thanks in advance!
Edit: Thanks everybody for your solutions!
Warning: Untested code. Try this, though.
This prints out: