使用PHP foreach的多行?
我试图用foreach-call创建一个包含4行的表。
我的问题是,在结果中我在同一列中得到每个ID二十次。
我正在使用此代码:
<table width="80%" border="0" cellpadding="10px">
<?php foreach (array_chunk($items, 4) as $row) { ?>
<?php
$i = 0;
foreach ($items as $item):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
} ?>
<tr
<?php echo $class;?>
>
<?php foreach ($row as $item){ ?>
<td>
<?php echo htmlentities ($item['Item']['id']); ?>
</td>
<?php } ?>
<?php endforeach; ?>
</tr>
<?php } ?>
</table>
知道如何才能获得每个ID一次吗?
没有找到相关结果
已邀请:
1 个回复
仇聘发栖
增加
而不是每
这是您正在寻找的修复方案吗? 编辑:Mikel有你的修复,添加这个来修复行错误(典型的我注意到第一个eck!)