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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:34:57+00:00 2026-06-03T22:34:57+00:00

I have images in an array and I want them to be display in

  • 0

I have images in an array and I want them to be display in a table with 3 columns!

So obviously in HTML, it is like:

<table>
    <tr>
        <td><img src="image1.jpg"></td>
        <td><img src="image2.jpg"></td>
        <td><img src="image3.jpg"></td>
    </tr>
    <!-- and so on... -->
</table>

So I want it to print out in PHP but the problem is the code.

My code is like this:

    $photos = array(     "image1",
                        "image2",
                        "image3",
                        "image4",
                        "image5",
            );
    foreach ($photos as $photo) {
        $i = 0;
        if ($i < 3) {
            echo '<td><center><img src="'.$photo.'.jpg"></td>';
            $i++;
        } elseif ($i == 3) {
            echo '</tr><tr>';
            $i = 0;
        }
    }

I don’t know what seems to be the problem and every time I echo out the variable $i, it echoes out like 11111111111111111111111111111111111111111111.

  • 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-03T22:34:58+00:00Added an answer on June 3, 2026 at 10:34 pm

    change this

    foreach ($photos as $photo) {
            $i = 0;
    

    to

    $i = 0;
    foreach ($photos as $photo) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of images images:[ {image: 'img/img01.jpg'}, {image: 'img/img02.jpg'}, ] I want
I have an observable array with var items= [ {image: /images/image1.jpg }, {image: /images/image2.jpg
I need to display array of images in a single view which have various
I have images that have different size (lower than 200x200 px) I want them
In a folder images I have a thousand xml files.Those filenames I want them
I have stored 5 images in an mutable array and displayed them randomly on
I have an images array in which there are number of images. Not fixed,
I need to get array of images that have to call from server and
i have two int array of images , i have implemented it in grid
I have image Array with two images out of that first image its showing

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.