Reputation: 10056
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>
Upvotes: 3
Views: 76
Reputation: 184
Shouldn't it be <?=(($i % 2) == 1) ? "</tr>" : null ?>
cause you have it <?=(($i % 2) == 0) ? "</tr>" : null ?>
Upvotes: 2