Skip to content

Instantly share code, notes, and snippets.

@yuraloginoff
Last active June 6, 2020 11:24
Show Gist options
  • Save yuraloginoff/6b169abd595848a71b2e to your computer and use it in GitHub Desktop.
Save yuraloginoff/6b169abd595848a71b2e to your computer and use it in GitHub Desktop.
Responsive layout PHP for loop
<div class="row">
<?php for ($i = 0; $i < count($news); $i++) { ?>
<?php if ($i == 0 ) {
echo '<div class="row">';
} else if ($i != 0 && $i % 4 == 0) {
echo '</div><div class="row">';
} ?>
<?php if ($i == (count($news)-1) && count($news) % 4 != 0) {
echo '<div class="column small-12 medium-6 large-3 item end">';
} else {
echo '<div class="column small-12 medium-6 large-3 item ">';
} ?>
<?php echo $news[$i]->title ;?>
</div>
<?php } ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment