Filling up the row before break column
13:46 02 Mar 2018

I wonder how to fill up a row of images before breaking. With my code, I can set how many images I want to display in every row, but if I want to fill the rows up and then breaking automatically.

enter image description here

This is my code:

$files = glob("images/*.*", GLOB_BRACE);

foreach ($files as $key => $file) {
 if ($key % 3 == 0) { // change 3 to how many items between rows
     if ($key != 0) { echo '
'.PHP_EOL; } echo '
'.PHP_EOL; } echo '
'.PHP_EOL; } ?>

Code: https://stackoverflow.com/users/661872/lawrence-cherone.

Don't really know how to credit

javascript php image for-loop image-gallery