Last active
June 6, 2020 11:24
-
-
Save yuraloginoff/6b169abd595848a71b2e to your computer and use it in GitHub Desktop.
Responsive layout PHP for loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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