My images gallery has a xhtml like below:
<div class="row">
<ul class="ul">
<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="ul">
<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 do this: Insert only 3 <li> in <ul> and close the after 3 <li>
What is the best way to do this? position ($pos = 0, $pos++) , array_chunk or anything else?
Thanks in advance
You have to prepare array of data.
We way you prepare it doesn’t really matter.
You can use $pos++ and set column markers in the data array.
and then output in in the template like this:
or you can use array_chunk and then use nested foreaches:
The latter one looks neat, I have to admit