Last active
May 31, 2023 16:07
-
-
Save brandonbarringer/007aad545fb8eed9ece4845700c83cea to your computer and use it in GitHub Desktop.
Stagger column number by row
This file contains hidden or 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 = array_fill(0, 16, 'item'); | |
$col = 0; | |
$row = 0; | |
foreach($items as $item) { | |
$col++; | |
if ($col > 4) { | |
$col = 1; | |
$row++; | |
} | |
$num = $col + $row > 4 ? $col + $row - 4 : $col + $row; | |
echo $num; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment