echo very 9th item of array a different code

Permalink
HI I have been trying to get my code to output a different script for every 9th item in an array, but i keep going in circles, to make it really simple please see below what i'm trying to do:

<ul class="sliderlogos">
   <li>
   <?php  foreach($customers as $customer){ ?>
        <?php $image = File::getByID($customer['image_id']); ?><?php echo $ih->outputThumbnail($image, 100, 50);?>   <!-- OUTPUT THIS FOR 1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,19... ETC... -->         
    <?php  } ?>
    <?php  foreach($customers as $customer){ ?>  
    </li>
    <li>
      <?php $image = File::getByID($customer['image_id']); ?><?php echo $ih->outputThumbnail($image, 100, 50);?>     <!-- OUTPUT THIS FOR 9,18,27... ETC... -->            
    <?php  } ?>
   </li>
</ul>


So ideally i end up with banks of 8 images in each li. I know it'll be a simple thing for someone, but i'm totally stumped!

Thanks in advance.

Ben

BHWW
 
ronyDdeveloper replied on at Permalink Best Answer Reply
ronyDdeveloper
You can use this condition

<ul class="sliderlogos">
   <?php  if($customers) { 
         $count = 0;
      foreach($customers as $customer) {
      $count++; 
   ?>
   <?php if($count % 9 == 0) { ?>
   <li class="set_class_for_9th_item"><?php $image = File::getByID($customer['image_id']); ?><?php echo $ih->outputThumbnail($image, 100, 50);?></li>
   <?php } else { ?>
   <li><?php $image = File::getByID($customer['image_id']); ?><?php echo $ih->outputThumbnail($image, 100, 50);?></li>
   <?php } ?>
   <?php  } ?>
</ul>


Rony
BHWW replied on at Permalink Reply
BHWW
Thanks Rory

I had to adjust it slightly but it was just what I was after, thanks very much for the fast response!

Ben