Skip to content
Advertisement

Put elements in a new bootstrap row after n number – foreach loop

I have an array of objects in which I want to iterate them in a foreach loop. However I want to only allow for 3 of them to be in a row and then after the 3rd, a new row to start, and so on.

JavaScript

So instead of 1 column in the row I would like 3

Advertisement

Answer

array_chunk is very usable here, e.g.:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement