I have a little problem on my website. I have a Blog and every article is in one list. Now I want to split this one list into 3 lists.
My Problem:
<ul class="row-3">
<?php $i = 1; foreach($posts as $post): ?>
<?php if($i % 3 == 0): ?>
<?php echo "$article" ?>
<?php endif; $i++; ?>
<?php endforeach ?>
</ul>
<ul class="row-2">
<?php $i = 1; foreach($posts as $post): ?>
<?php if($i % 2 == 0): ?>
<?php echo "$article" ?>
<?php endif; $i++; ?>
<?php endforeach ?>
</ul>
If I make it like this will every third loop go into the third list and every second loop into the second list. But the problem is:
Article 5 and 10 will be in both lists...
So I have to split the whole foreach-loop into 3 parts that a counter count until 3 and then if its at 3 it changes to 0 again so I can put every 1 into the first list every 2 into the second and every 3 into the third list but I have absolutely no idea how I can solve this.
I hope you guys can help me a bit and I'm sorry for my bad english..
Thanks a lot.