所以我有一个<tr>
,我想每隔 2 次打开<tr>
并关闭一次</tr>
所以我试过这个:
<?php $i = 0; foreach($blogs as $story): ?>
<?=(($i % 2) == 0) ? "<tr>" : null ?>
<td>my stuff</td>
<?=(($i % 2) == 0) ? "</tr>" : null ?>
<?php ++$i; endforeach; ?>
但它每次都会增加,我需要有一个<tr>
里面有两个<td>
<tr><td></td><td></td></tr>
不应该
是<?=(($i % 2) == 1) ? "</tr>" : null ?>
因为你有它<?=(($i % 2) == 0) ? "</tr>" : null ?>