问题是我如何打印collection
进入视野。第一个 div 只打印Collection 0
和下一个Collection ++
像这样
ExamsController@create
$collections = $questions->split(5);
$collections->toArray();
dd($collections);
dd($集合);
Collection {#455 ▼
#items: array:5 [▼
0 => Collection {#394 ▶}
1 => Collection {#619 ▶}
2 => Collection {#407 ▶}
3 => Collection {#398 ▶}
4 => Collection {#275 ▶}
]
}
创建.blade.php
<div>@foreach($collections as $collection)
收藏 0
@endforeach</div>
<div>@foreach($collections as $collection)
收藏1
@endforeach</div>
<div>@foreach($collections as $collection)
收藏2
@endforeach</div>
<div>@foreach($collections as $collection)
收藏3
@endforeach</div>
<div>@foreach($collections as $collection)
收藏4
@endforeach</div>
Use index
获取特定的collections
@foreach($collections[0] as $collection) //here $collection is Collection 0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)