I am trying to group each 5 loop items inside a <li></li> and then further group the each li item into two groups, so that first item of each li is in one group, while other 4 are in other group.
With the following code, I can wrap each 5 items of a loop in a li, but I am not able to group each li items into 2 groups. Since there are more than 10 items in the loop, thats why I can not hard code the values of $i to print the div.
$i = 1;
while ($i < 10){
echo ($i % 5 === 0) ? "<li>" : null;
$i++;
echo item $i;
echo ($i % 5 === 0) ? "</li>" : null;
}
echo ($i % 5 !== 0) ? "</li>" : null;
This is the desired output:
<li>
<div class="left">
Item 1
</div>
<div class="right">
Item 2
Item 3
Item 4
Item 5
</div>
</li>
<li>
<div class="left">
Item 6
</div>
<div class="right">
Item 7
Item 8
Item 9
Item 10
</div>
</li>
Working example: http://codepad.org/uHYHl6MD