Add tr element on even number

Viewed 70

So I have a <tr> which I want to open <tr> and close </tr> every 2nd time

So I have tried this:

<?php $i = 0; foreach($blogs as $story): ?>
<?=(($i % 2) == 0) ? "<tr>" : null ?>
 <td>my stuff</td>
<?=(($i % 2) == 0) ? "</tr>" : null ?>
<?php ++$i; endforeach; ?>

But it adds every time, my need is to have one <tr> with two <td> inside

<tr><td></td><td></td></tr>
1 Answers
Related