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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:40:55+00:00 2026-06-16T05:40:55+00:00

Need a little help with a solution for this problem. I have a list

  • 0

Need a little help with a solution for this problem. I have a list of services that is generated as such:

<div class="row">
    <?php foreach( $entries as $s ) : ?>
    <?php require( dirname(__FILE__) . '/_index_DisplayService.php' ); ?>

    <?php endforeach; ?>
</div>

_index_DisplayService.php

<div class="grid-4">
    <div id="service-mobile-dev" class="service">   
        <div class="service-icon">
            <i class="icon-calendar"></i>
        </div>
    </div>
</div>

Now this is a grid-12 layout, so I need 3, grid-4 per row then new row. I think that a solution starts with moving the <div class="row"> below <?php foreach( $entries as $s ) : ?> looking something like this:

<?php foreach( $entries as $s ) : ?>
    <div class="row">
        <?php require( dirname(__FILE__) . '/_index_DisplayService.php' ); ?>
    </div>
<?php endforeach; ?>

This of course kicks everything to a single row. How do I go about generating 3 grid-4’s per row.

Thanks!

  • 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-16T05:40:57+00:00Added an answer on June 16, 2026 at 5:40 am

    You can use the index => value properties in a foreach (or replace it entirely with a for loop) and run a modulo on the index to insert the row div conditionally. Assuming $entries is an array.

    <?php
        foreach ($entries as $key => $value) :
            
            // Close the "previous" row tag before beginning the next row
            // Obviously we should not start with a closing tag ($key > 0)
            if ($key > 0 && $key%3 == 0) {
                ?>
                </div>
                <?php
            }
            
            // Start a new row
            if ($key%3 == 0) {
                ?>
                <div class="row">
                <?php
            }
            
            // Insert the "grid-4" elements
            require dirname(__FILE__) . '/_index_DisplayService.php';
    
        endforeach;
        
        // If there were any entries then we have a row which hasn't been closed yet.
        // Close it.
        if (count($entries) > 0) {
            ?>
                </div>
            <?php
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need a little help with a SQL / ActiveRecord query. Let's say I have
I need a little help getting this script doing what I want it to.
I need little help regarding sharepoint solution set up in sharepoint. I created wspbuilder
I have a little problem where need to do a hash of a number
I have a little DB challenge for you. Hopefully you can help. The Problem:
hey guys, somehow i can't find the solution for my little problem. i have
I just need a little help how to organize my code. This is not
Need a little help with this script. It's working but I'd love a way
I need little help for url rewriting in wordpress. basically what i need: mydomain.com/mysomewordpresspost
I would need little help here. I'm trying to get the git respository from

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.