Items in row : PHP image gallery

My images gallery’ htm il like this :


<div class="row">
  <ul class="galleryUl">
    <li><a href="#"><img src=....></a></li>
    <li><a href="#"><img src=....></a></li>
    <li><a href="#"><img src=....></a></li>
  </ul>
</div>
<div class="row">
  <ul class="galleryUl">
    <li><a href="#"><img src=....></a></li>
    <li><a href="#"><img src=....></a></li>
    <li><a href="#"><img src=....></a></li>
  </ul>
</div>

I want to specify only 3 <li> in ul and after this repeated the <div class=“row”>. How can specify this with php?
Thanks in advance.

lol

Your spam answer chose me too :wink:

A lot is two words. Sorry to be a pedant, I didn’t choose this crusade, it chose me.

Thanks alot .

[fphp]array_chunk/fphp could probably help here. :slight_smile:


<?php
$images = array(
    'me.jpg',
    'you.bmp',
    'foo.png',
    'bar.gif'
);
?>

<?php foreach(array_chunk($images, 1) as $row): ?>
<div class="row">
    <ul class="galleryUl">
        <?php foreach($row as $image): ?>
            <li>
                <a href="#">
                    <img src="<?php echo $image; ?>" />
                </a>
            </li>
        <?php endforeach; ?>
    </ul>
</div> 
<?php endforeach; ?>