简体   繁体   English

如何创建<ul>每10个东西<li>创建?</li></ul>

[英]how to create <ul> thing for each 10 <li> created?

I need to create every 10 records of the new <ul> to store the rest.我需要每 10 条记录创建新的<ul>来存储 rest。 The idea is that every 10 <li> he creates another <ul> block that will contain 10 more and so on.这个想法是每 10 个<li>他创建另一个<ul>块,该块将包含 10 个以上,依此类推。

What is returned from the bank in blade:在刀片中从银行返回的内容:在此处输入图像描述

As I'm trying to do with the following result now:正如我现在正在尝试处理以下结果:在此处输入图像描述

Can someone help me?有人能帮我吗?

Via array_chunk() you can split your array into chunks of 10 items (or less if it's the last chunk).通过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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM