Skip to content Skip to sidebar Skip to footer

Looping Data Which Contains 3 Column Each Row

My problem is divide 3 columns each row image : https://imgur.com/iYWideu
@foreach($pr

Solution 1:

Just chunk your data into sets of 3 and add a nested loop to iterate each set's data.

foreach (array_chunk($products, 3) as $set) {
    echo '<div class="row">';
        foreach ($set as $product) {
            echo '<div class="col-lg-4 col-md-4">';
                ...
            echo '</div>';
        }
   echo '</div>';
}

Post a Comment for "Looping Data Which Contains 3 Column Each Row"