0
我有这段代码将所有结果显示为图标,但它显示每个循环中将近50个图标。我搜索了许多方法,在每个循环中将其更改为3个图标失败。我怎样才能做到这一点?如何在PHP中将foreach循环限制为3个结果图标?
foreach ($categoryItems as $item) {
if ($item['categoryId'] != $category['id'])
continue;
$itemXML = $items->findItemInXML($item['itemId']);
$subContent .= "<a class=\"thumbnail\" ><img src=\"images/gameIcons/".$items->getIcon($itemXML).".png\" alt=\"Item icon\" align=\"top\" />";
}
$subContent .= "</td>
<td class=\"tablePreview ui-state-hover\">
<a href=\"showMore\">More information</a>
</td>
</tr>";
为什么不使用'for'循环呢? –