Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 904169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:00:24+00:00 2026-05-15T16:00:24+00:00

My images gallery has a xhtml like below: <div class=row> <ul class=ul> <li><a href=#><img

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:00:24+00:00Added an answer on May 15, 2026 at 4:00 pm

    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:

    <? foreach ($DATA as $row): ?>
    <? if($row['ul']): ?>
    <div class="row">
     <ul class="ul">
    <? endif ?>
      <li><a href="<?=$row['url']?>"><img src="<?=$row['src']?>"></a></li>
    <? if($row['/ul']): ?>
     </ul>
    </div>
    <? endif ?>
    

    or you can use array_chunk and then use nested foreaches:

    <? foreach ($DATA as $arr): ?>
    <div class="row">
     <ul class="ul">
     <? foreach ($arr as $row): ?>
       <li><a href="<?=$row['url']?>"><img src="<?=$row['src']?>"></a></li>
     <? endforeach ?>
     </ul>
    </div>
    <? endforeach ?>
    

    The latter one looks neat, I have to admit

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My div has many images like <div id=gallery> <img src=images/flowing-rock.jpg alt=Flowing Rock width=580 height=360
This website has a gallery of images. Each time I click on a thumbnail
So i have a picture gallery with eight categories. Each category has 400+ images,
I've an image gallery, that displays images in a 5X5 matrix. Each image has
I preparing a images gallery,I want to ZoomIn and ZoomOut of images which are
I have a gallery of images on my website. Under each one, I'd like
I want to navigate to previous and next images in my gallery on swiping
I have these two tables: Galleries - {id,title,description} Images - {id,gallery_id,file} Each gallery has
I'm creating an application that has a Gallery , and this Gallery has a
<div id=image_div> <input type=checkbox /> <img src=1.jpg /> <input type=checkbox /> <img src=2.jpg />

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.