Created
September 25, 2015 08:53
-
-
Save josuecau/ce32ee536c9c5002ec5a to your computer and use it in GitHub Desktop.
Split list into groups
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
<ol> | |
<li>A</li> | |
<li>B</li> | |
<li>C</li> | |
</ol> | |
<ol> | |
<li>D</li> | |
<li>E</li> | |
<li>F</li> | |
</ol> | |
<ol> | |
<li>G</li> | |
<li>H</li> | |
<li>I</li> | |
</ol> | |
<ol> | |
<li>J</li> | |
<li>K</li> | |
<li>L</li> | |
</ol> | |
<ol> | |
<li>M</li> | |
<li>N</li> | |
<li>O</li> | |
</ol> | |
<ol> | |
<li>P</li> | |
<li>Q</li> | |
<li>R</li> | |
</ol> | |
<ol> | |
<li>S</li> | |
<li>T</li> | |
<li>U</li> | |
</ol> | |
<ol> | |
<li>V</li> | |
<li>W</li> | |
<li>X</li> | |
</ol> | |
<ol> | |
<li>Y</li> | |
<li>Z</li> | |
</ol> |
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 $items = range('A', 'Z'); $groupBy = 3; ?> | |
<ol> | |
<?php foreach ($items as $i => $item): ?> | |
<li><?php echo $item; ?></li> | |
<?php $j = $i + 1; ?> | |
<?php if ($j < count($items) && $j % $groupBy === 0): ?> | |
</ol> | |
<ol> | |
<?php endif; ?> | |
<?php endforeach; ?> | |
</ol> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment