Skip to content

Instantly share code, notes, and snippets.

@asifsomy
Last active January 6, 2016 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asifsomy/e33b4adbba7248cb6875 to your computer and use it in GitHub Desktop.
Save asifsomy/e33b4adbba7248cb6875 to your computer and use it in GitHub Desktop.
Wrap n number of divs into a parent div
<?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