Skip to content

Instantly share code, notes, and snippets.

@williambeeler
Created June 18, 2019 12: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 williambeeler/fa9b9bb92446a8d185b8629cf8155ea6 to your computer and use it in GitHub Desktop.
Save williambeeler/fa9b9bb92446a8d185b8629cf8155ea6 to your computer and use it in GitHub Desktop.
<?php
$count = 1;
foreach( $items as $item )
{
if ($count%5 == 1)
{
echo '<div class="5-results-wrapper">';
}
echo '<p>Some item</p>';
if ($count%5 == 0)
{
echo "</div>";
}
$count++;
}
//This is to ensure there is no open div if the number of elements is not a multiple of 5
if ($count%5 != 1) echo "</div>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment