I need to HTML table output like:<table><tr>    <td>ITEM<td>    <td>ITEM<td>    <td>ITEM<td></tr></table><table><tr>    <td>ITEM<td>    <td>ITEM<td>    <td>ITEM<td></tr></table><table><tr>    <td>ITEM<td>    <td>ITEM<td>    <td>ITEM<td></tr></table>My code before:<?php $i = 1;?><?php foreach ($items as $item): ?><?php if ($i == 1 || $i == 4 || $i == 7 ......): ?><table><tr><?php endif; ?>    <td> CONTENT </td><?php if ($i == 3 || $i == 6 || $i == 9 ......):?></table></tr><?php endif;?><?php $i++ ?>                                                           <?php endforeach; ?>My code now:<?php $i = 1;?><?php foreach ($items as $item): ?><?php if ($i % 3 == 1): ?><table><tr><?php endif; ?>    <td> CONTENT </td><?php if ($i % 3 == 0):?></table></tr><?php endif;?><?php $i++ ?>                                                           <?php endforeach; ?>
Optimizing code for foreach
php