Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created October 10, 2016 11:37
Show Gist options
  • Select an option

  • Save hsleonis/b8ba6c59550ef417dbfded24a16fd1da to your computer and use it in GitHub Desktop.

Select an option

Save hsleonis/b8ba6c59550ef417dbfded24a16fd1da to your computer and use it in GitHub Desktop.
Prints two row with single items
<?php
// Items
$n = 18;
$iterator = ($n>4)?2:1;
echo '[ CONTAINER ]<br />';
for($i=0;$i<$n;$i+=$iterator){
echo '[ * col * ]';
echo "{ item ".($i)." }";
if(($n==5 && $i==2) or ($n==6 && $i==4)) {
$iterator=1;
echo '[ * /col * ]<br />';
continue;
}
if($iterator==2 && $i+1<$n) echo "{ item ".($i+1)." }";
echo '[ * /col * ]<br />';
}
echo '[ /CONTAINER ]';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment