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

  • Home
  • SEARCH
  • 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 6761995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:15:37+00:00 2026-05-26T14:15:37+00:00

I have product list ( 9 products in multidimensional array ), i want to

  • 0

I have product list ( 9 products in multidimensional array ), i want to achieve that all 9 product will be ordered in 3 div columns.
for example

 product1       product4       product7
 product2       product5       product8
 product3       product6       product9

And my array structure is

array(
  array(product_name1),
  array(product_name2),
  array(product_name3),
  array(produ‌​ct_name4),
  array(product_name5)
)

i have html code how this must look like

<div class="container">
<div class="prod-column">
    <div class="product-slot">
        product1
    </div>
    <div class="product-slot">
        product2
    </div>
    <div class="product-slot">
        product3
    </div>
</div> <!-- close column -->
<div class="prod-column">
    <div class="product-slot">
        product4
    </div>
    <div class="product-slot">
        product5
    </div>
    <div class="product-slot">
        product6
    </div>
</div> <!-- close column -->
<div class="prod-column">
    <div class="product-slot">
        product7
    </div>
    <div class="product-slot">
        product8
    </div>
    <div class="product-slot">
        product9
    </div>
</div> <!-- close column -->
</div> <!-- close container -->

Also i find code on Answered here

but in my case i’ve got blank row at end, i can’t find a reason why i’ve got this empty prod-column at end

Thanks for help 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-26T14:15:38+00:00Added an answer on May 26, 2026 at 2:15 pm

    Try this. Assumes your product name is the first element of an indexed array – if it isn’t, modify $array[$i][0] appropriately. Also assumes you have a number of products divisible by three (which presumably wont always be the case) so it doesn’t generate empty filler fields, but hopefully it will give you the idea.

    echo "<div class=\"container\">\n";
    
    for ($i = 0, $j = 0; isset($array[$i]); $i++) {
      if ($j == 0) {
        echo "<div class=\"prod-column\">\n";
      }
      echo "    <div class=\"product-slot\">\n        {$array[$i][0]}\n    </div>\n";
      if ($j == 2) {
        echo "</div>\n";
        $j = 0;
      } else $j++;
    }
    
    echo "</div>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Products:List<Product> class. I'd like to make it so that every time
I have a product list that put 3 products on a row and clears
i have a list of products that are being displayed in particular order. store
I have a order list and I want to generate and rank the product
I have the following menu: <ul class=top-menu> <li><a_href=/Products title=Products><span>Products</span></a><ul> <li><a_href=/Products/List title=Product List><span>Product List</span></a></li> </ul>
I have two tables, product and sold_record . product contains my list of products,
Below are my classes. I have a product that contains list of days. Each
I have a product expiring list. In this list I will show only the
I have long list of products and in each product i have form: <form
So say I have a products table with a list of products, and one

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.