【发布时间】:2016-07-30 05:51:32
【问题描述】:
我在集合中的集合看起来像这样:
=> [
[
"id" => 3,
"parent_id" => 2,
"depth" => 1,
"children" => [
[
"id" => 4,
"parent_id" => 3,
"depth" => 2,
"children" => [
[
"id" => 5,
"parent_id" => 4,
"depth" => 3,
"children" => [
[
[...]
我该怎么做?
$result->count();
这个返回1
它的行为就像只有 1 个集合,所以我什至不能使用 map 或 each 来过滤它。我需要过滤最大深度为 4。
我试过reject(),但也没有用。
我可以将它转换为数组,但我想使用不错的收集方法...
【问题讨论】:
标签: php laravel collections