Last active
January 6, 2016 13:15
-
-
Save asifsomy/e33b4adbba7248cb6875 to your computer and use it in GitHub Desktop.
Wrap n number of divs into a parent div
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
<?php | |
$i=0; | |
$wrap_count = 4; // you can change this no of divs to wrap | |
foreach ($categories as $category) | |
{ | |
$i+=1; | |
if($i%$wrap_count==1) | |
echo '<div class="row">'; | |
?> | |
<div class="col-lg-3 col-md-3">.....</div> | |
<?php | |
if($i%$wrap_count==0) | |
echo '</div>'; | |
} | |
if($i%$wrap_count!=0) | |
echo '</div>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment