所以我希望完成的是:
<div class="product-box">
<ul class="product-list">
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span>
</a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
<li><a href="http://sauritchsurfboards.com/longboards.html" title="Surfboards _ San Diego Surfboard Shapers _ Sauritch Surfboards-2" target="_blank"><span>Surfboards _ San...</span></a></li>
</ul>
</div>
我有一个$griditems
来自数据库的数组。
我想展示 6 个 .product-box'es,<li>
里面有 6 个,来自这个$griditems
通常我会这样做:
<div class="product-box">
<ul class="product-list">
<?php
$count=1;
foreach($griditems as $item)
{
if($count == 6) { break; }
?>
<li><a>.....</a></li>
<?php
$count++;
}
?>
</ul>
</div>
但这在这种情况下不起作用,因为我希望有 6 个这些 .product-box 类,并且每个 .product-box 内部应该有这 6 个项目,它们应该彼此继续,而不是重复相同的前 6 个存在于$griditems
数组中。
我怎样才能做到这一点?