php-Laravel拆分收集方法

问题是如何将收藏夹打印到视图中.并且第一个div仅打印Collection 0,而下一个Collection这样打印

ExamsController @创建

$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 ▶}
]
}

Create.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> 

解决方法:

使用索引获取特定集合

@foreach($collections[0] as $collection) //here $collection is Collection 0

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...