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 8577545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:11:02+00:00 2026-06-11T20:11:02+00:00

I print img html elements by a foreach cycle. Images are stored in db

  • 0

I print img html elements by a foreach cycle.

Images are stored in db so if they are 40 foreach will print 40 img

Now i need that if they are 40 in db and i need to print 100 img elements, to repeat the cycle until they are 100, is it possible to do that?

EDIT:

to be clear, i retrieve 40 img from db, i need to print “100 OF THEM” (repeat them if they are less than 100) … hope is clear 😛

  • 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-06-11T20:11:03+00:00Added an answer on June 11, 2026 at 8:11 pm

    You can use Iterators:

    $images = new LimitIterator(
        new InfiniteIterator(
            new ArrayIterator($imgArray)
        ), 
        0, 100
    );
    
    foreach ($images as $image) {
        // print images
    }
    

    The ArrayIterator makes your $imgArray iterateable by other Iterators. The InfiniteIterator will make the wrapped ArrayIterator start over at the beginning when it has reached the end of $imgArray. Finally, the LimitIterator will limit the iteration to 100 items.

    So, when you iterate over $images, foreach will go over the elements in the image array repeating them over and over until 100 elements have been printed, e.g. this will output images 1-40, then again 1-40 and finally 1-20 because 40+40+20=100.

    Demo: http://codepad.org/YeDgpsVc

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

Sidebar

Related Questions

In other topics I've found that IE/FF doesn't print background images by default .
I'm trying to insert a placeholder in html code that will be replaced later
My code: year=[51-52,53,55,56,58,59,60,61] photo=[{70,72,73},{64,65,68},{79,80,81,82},{74,77,78},{60,61,62},{84,85,87},{57,58,59},{53,54,55,56}] for i in range(7): print <img src=\http://files.getdropbox.com/u/100000/Akuja/,year,/P10104,photo,.JPG\> I run it
I have a JavaScript file that prints the title attribute of the child img
Print all combinations of a number N, as a sum of positive integers? They
print <ul>; foreach ($arr as $value) { echo(<li> . $value[storeid] . . ($value[dvdstock] +
I have a simple function in jQuery that creates new elements in the DOM.
I have created a highlight feature that will highlight anything contained in a <p>
(I only need functionality in Chrome) Context: I'm hacking together a node.js script that
My original HTML looks something like this: <h1>Page Title</h1> <h2>Title of segment one</h2> <img

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.