我在joomla创建一个模块时遇到了问题。我的php技能受到限制。我使用foreach在模板文件中显示元素:
<?php foreach ($filtered_array as $index=>$value) { ?>
<div>show information></>
<?php } ?>如何使用array_chunk将3元素分组到一个div中,将下一个元素分组到另一个div中?
谢谢你的帮助!
发布于 2015-10-30 08:08:48
只需按照您的要求使用array_chunk和嵌套循环即可。
<?php foreach (array_chunk($filtered_array, 3) as $row): ?>
<?php foreach ($row as $value): ?>
<div>show information></div>
<?php endforeach; ?>
<?php endforeach; ?>https://stackoverflow.com/questions/33431204
复制相似问题