如何解决如何为每创建 10 个 <li> 创建 <ul> 东西?
我需要每 10 条记录创建新的 <ul>
以存储其余记录。
这个想法是每 10 <li>
他创建另一个 <ul>
块,其中将包含 10 等等。
从刀片银行返回的内容:
因为我现在正在尝试处理以下结果:
有人可以帮我吗?
解决方法
通过 array_chunk()
,您可以将数组拆分为 10 个项目的块(如果是最后一个块,则更少)。
@php
$chunks = array_chunk($category->recursiveChildren,10);
@endphp
@foreach($chunks as $chunk)
<ul>
@foreach($chunk as $child)
<li>{{ $child }}</li>
@endforeach
</ul>
@endforeach
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。