Skip to content

Instantly share code, notes, and snippets.

@lekankoku
Created September 16, 2017 23:02
Show Gist options
  • Save lekankoku/604c1645adc5cef70008f70414f6559d to your computer and use it in GitHub Desktop.
Save lekankoku/604c1645adc5cef70008f70414f6559d to your computer and use it in GitHub Desktop.
Dynamic Bootstrap Row and Column Maker
<?php
$numberOfColumns = 3;
$bootstrapColWidth = 12 / $numberOfColumns ;
$chunkArray = array_chunk($items, $numberOfColumns);
foreach($chunkArray as $items) {
echo '<div class="row">';
foreach($items as $item) {
echo '<div class="col-md-'.$bootstrapColWidth.'">';
// your item
echo '</div>';
}
echo '</div>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment