Skip to content

Instantly share code, notes, and snippets.

@ahmad-moussawi
Created April 16, 2016 06:13
Show Gist options
  • Save ahmad-moussawi/b36d020f374a2ee8d8cb8a2d1de62d8e to your computer and use it in GitHub Desktop.
Save ahmad-moussawi/b36d020f374a2ee8d8cb8a2d1de62d8e to your computer and use it in GitHub Desktop.
Row Grouping
<?php
$i = 0;
$col = 5; // number of items per row
$width = 100/ $count;
$count = count($items)
?>
<div class="white-box gallery">
<?php foreach($items as $item): ?>
<?php if($i % $col === 0): ?>
<div class="row">
<?php endif ?>
<a style="width:<?php echo $width ?>%;" href="img/product_1.jpg">
<img src="img/product_1.jpg" alt="">
</a>
<?php if( ($i + 1) % $col === 0 || ($count - ($i - 1) === $count % $col)): ?>
</div> <!-- // .row -->
<?php endif ?>
<?php $i++; endforeach ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment