The output look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<div> kicks brand kicks brand kicks brand kicks brand </div> <div> kicks brand kicks brand kicks brand kicks brand </div> <div> kicks brand kicks brand kicks brand kicks brand </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$count = 1; foreach( $array_var as $var ) { if ($count%4 == 1) { echo "<div>"; } // Code if ($count%4 == 0) { echo "</div>"; } $count++; } if ($count%4 != 1) echo "</div>"; //This is to ensure there is no open div if the number of elements in user_kicks is not a multiple of 4 |