Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

madsem's avatar

Blade Recursion with multi-dimen. Collection (Unknown Depth) -> does my head in

So I'm trying to display a "Group By" report in a HTML table.

The user selects group by conditions from a set of select fields, between 1 - 3. For example:

Group by 1: Domain Then Group By 2: Storefront Then Group By 3: Browser

<table>
<thead>
...
</thead>
<tbody>
    <tr>
        <th scope="row" colspan="12" class="alert-info pl-1">
            Domain1.com
        </th>
    </tr>
    <tr>
        <th scope="row" colspan="12" class="alert-info pl-2">
            v1
        </th>
    </tr>
    <tr>
        <th scope="row" class="pl-3">↪ chrome</th>
        <td>Mark</td>
        <td>Otto</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
    </tr>
    <tr>
        <th scope="row" class="pl-3">↪ internet explorer</th>
        <td>Mark</td>
        <td>Otto</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
        <td>@mdo</td>
    </tr>
<tr>
        <th scope="row" colspan="12" class="alert-info pl-1">
            Domain2.com
        </th>
    </tr>
    <tr>
        <th scope="row" colspan="12" class="alert-info pl-2">
            v2
        </th>
    </tr>
...
...
...
    </tbody>
</table>

This here is the Collection I have to display the table:

Collection {#1329 ▼
  #items: array:6 [▼
    "domain1.com" => Collection {#1144 ▼
      #items: array:4 [▼
        "v1" => Collection {#1122 ▼
          #items: array:5 [▼
            "chrome" => Collection {#1117 ▼
              #items: array:1 [▼
                0 => {#927 ▼
                  +"product_group": "group_1"
                  +"views": "17"
                  +"visits": "5"
                  +"clicks": "19"
                  +"conversions": "14"
                  +"revenue": "12.51"
                  +"domain_name": "domain1.com"
                  +"store_version": "v1"
                  +"browser": "chrome"
                }
              ]
            }
            "firefox" => Collection {#1118 ▶}
            "internet explorer" => Collection {#1119 ▶}
            "microsoft edge" => Collection {#1120 ▶}
            "safari" => Collection {#1121 ▶}
          ]
        }
        "v2" => Collection {#1129 ▶}
        "v3" => Collection {#1136 ▶}
        "v4" => Collection {#1143 ▶}
      ]
    }
    "domain2.com" => Collection {#1181 ▶}
    "domain3.com" => Collection {#1217 ▶}
    "domain4.com" => Collection {#1254 ▶}
    "domain5.com" => Collection {#1291 ▶}
    "domain6.com" => Collection {#1328 ▶}
  ]
}

Recursion in Blade:

@foreach ($rows as $key => $row)
    @include('partials.rows', [
                        'key' => $key,
                        'row' => $row
                    ])
    @endforeach 

Then the partial template:

@if($row instanceof \Illuminate\Support\Collection)
    
    @foreach($row as $key => $child)
        @include('partials.rows', [
            'key' => $key,
            'row' => $child
        ])

        @if(! $loop->last)
            <tr>
                <th scope="row" colspan="12" class="alert-info pl-{{ $loop->depth }}">
                    {{ $key }}
                </th>
            </tr>
        @else
            <tr>
                <th scope="row" class="pl-{{ $loop->depth }}">
                    ↪
                    {{ $key }}
                </th>
                <td>{{ $child->views }}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        @endif
    @endforeach
@endif 

The problem comes now where I am trying to display the metrics in the final row of each array inside the last collection.

There is an error like:

"Property [views] does not exist on this collection instance."

But it clearly does exist, when I do a die & dump in the above table structure in the @else I get this result:

 @else
            {{ dd($child) }}
            <tr>

gives:

{#927 ▼
  +"product_group": "group_1"
  +"views": "17"
  +"visits": "5"
  +"clicks": "19"
  +"conversions": "14"
  +"revenue": "12.51"
  +"domain_name": "domain1.com"
  +"store_version": "v1"
  +"browser": "chrome"
}

So, my head hurts :)

Do you guys have a better way how to achieve what I want? Or see where I am going wrong in the above?

Thank you!

0 likes
33 replies
lostdreamer_nl's avatar

You're looping over a collection, and 1 of them does not have the 'views' key. That the first one you dd() does have it does not say much about the rest of the collection.

At the least: 1 of those rows does not have the 'views' set. Try this:


<td>
    @if(isSet($child->views))
        {{ $child->views }}
    @else 
        {!! dd($child); !!}
    @endif
</td>

This should show you which row is breaking.

madsem's avatar

hey @lostdreamer_nl thanks, I also tried something similar before. Here is the result:

@else
            @if(isSet($child->views))
                {{ $child->views }}
            @else
                {!! dd($child); !!}
            @endif
            <tr>
                <th scope="row" class="pl-{{ $loop->depth }}">
                    ↪
                    {{ $key }}
                </th>
                <td>{{ $child->views }}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        @endif 

result:

17 13 22 10 3
Collection {#1121 ▼
  #items: array:1 [▼
    0 => {#931 ▼
      +"product_group": "group_1"
      +"views": "3"
      +"visits": "1"
      +"clicks": "3"
      +"conversions": "1"
      +"revenue": "1.25"
      +"domain_name": "domain1.com"
      +"store_version": "v1"
      +"browser": "safari"
    }
  ]
}

Really at my wits end atm :D Is it possible I messed up the recursion here? And that is why this is happening?

36864's avatar

You're calling views on a collection, not on an element. Even if your collection only has one element in it, this won't work.

You'll need to iterate over that collection and call views on each member.

madsem's avatar

Sorry @36864 I don't quite follow, can you go a bit more into detail

Maybe a code example?

36864's avatar

The last code sample you posted shows that you're expecting to receive an object, but actually you're receiving a collection that only has one element in it.

If at this point you're only expecting one element, you could change your code to first fetch the first element of the collection (which would be the only element):

@else
  <tr>
    <th scope="row" class="pl-{{ $loop->depth }}">
       {{ $key }}
    </th>
    <td>{{ $child->first()->views }}</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
@endif 
madsem's avatar

@36864 did you see the numbers on top of the output I pasted though? So I am not just receiving a one element collection, I'm actually receiving the expected output until a certain point.

here, the views are printed and then the collection (which is the same collection that has 3 views and safari browser, that was actually printed before above.

17 13 22 10 3
Collection {#1121 ▼
  #items: array:1 [▼
    0 => {#931 ▼

Which is why I'm so confused.

If I try your code I just get a:

"Call to undefined method stdClass::first()"
@if($row instanceof \Illuminate\Support\Collection)
    
    @foreach($row as $key => $child)
        @include('partials.rows', [
            'key' => $key,
            'row' => $child
        ])
        @if(! $loop->last)
            <tr>
                <th scope="row" colspan="12" class="alert-info pl-{{ $loop->depth }}">
                    {{ $key }}
                </th>
            </tr>
        @else
            <tr>
                <th scope="row" class="pl-{{ $loop->depth }}">
                    ↪
                    {{ $key }}
                </th>
                <td>{{ $child->first()->views }}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        @endif
    @endforeach
    
@endif
36864's avatar

How about

@else
  <tr>
    <th scope="row" class="pl-{{ $loop->depth }}">
      {{ $key }}
    </th>
    @if(isSet($child->views))
      <td>{{ $child->views }}</td>
    @else
      <td></td>
    @endif
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
@endif 
madsem's avatar

@36864 so the parent loop:

@foreach ($rows as $key => $row)
    @include('partials.rows', [
                        'key' => $key,
                        'row' => $row
                    ])
    @endforeach 

And then the child from post above, and that messes it up somehow maybe? Because the weird thing that the 17 13 22 10 3 are printed

And these are the exact views from all child collections, the "3" is the last item. But then for some reason the whole loop seems to be executed again and fails and the collection is dumped that was printed fine the iteration before.

madsem's avatar

@36864 so your latest code snippet does show the page views and now for some reason the other grouping headers are missing.

There is something messed up with the recursion in my template, I just don't know what.

Screen_Shot_2018_05_14_at_11_15_56_AM

36864's avatar

Basically, you're iterating over a collection of collections. The way your recursion is set up, you first print out the inner-most elements, then you try to print each collection as if it were an inner-most element.

If you have Group 1 > Group 2 > Group 3 > Element

what you're trying to print out is:

$element->views
$group3->views
$group2->views
$group1->views

Since $group1, $group2, and $group3 are Collections, they don't have a views property and that's what's causing the error.

For this to work you'd need to abort your partial after printing the inner-most collection

madsem's avatar

@36864 you are right :) That's why I was using:

@if(! $loop->last)

To try to only access ->views inside the final array element of each collection. But for some reason it is a huge mess now and doesn't work right.

Do you have a better way how I can loop through this dynamic depth collection?

Teach me haha

madsem's avatar

@36864 Also for some reason (and this is the cause of the errors) it seems the whole collection is looped through twice:

I do this:

@if($row instanceof \Illuminate\Support\Collection)
    
    @foreach($row as $key => $child)
        @include('partials.rows', [
            'row' => $child
        ])
        @if(! $loop->last)
            <tr>
                <th scope="row" colspan="12" class="alert-info pl-{{ $loop->depth }}">
                    {{ $key }}
                </th>
            </tr>
        @else
            <tr>
                <th scope="row" class="pl-{{ $loop->depth }}">
                
                </th>
                @if(isSet($child->views))
                    lalala
                    <td>{{ $child->views }}</td>
                @else
                    <td></td>
                @endif
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        @endif
    @endforeach
    
@endif 

and this is the result: Screen_Shot_2018_05_14_at_11_35_16_AM

36864's avatar

The $loop variable is local to each @foreach loop.

I guess if I were doing this, I'd have two partials: One for groups, and one for leaf nodes.

Then do something like

//partials.group
@foreach($elements as $key => $element)
    @if($element instanceof Illuminate\Support\Collection)
        @include('partials.group', ['elements' => $element])
        //any additional rendering with the groups, i.e. {{$key}}
    @else
        @include('partials.leaf')
    @endif
@endforeach

//partials.leaf
{{$element->property}}
madsem's avatar

@36864 hey thank you, this is def. a bit cleaner than mine.

But the problem is, this doesn't give me the table structure I need which I posted in the original topic.

so I need the table to be like:

group 1 value
    group 2 value
        group 3 value_1 | 12 | 10 | 23 | ...
group 1 value
    group 2 value
        group 3 value_2 | 12 | 10 | 23 | ...
...

And no matter how I structure the recursive loop, also your version, I never seem to be able to achieve this structure.

(The reason for the errors in the OT was exactly this also, yours is very close to what I was doing in the beginning, but because I need to get the inner-most elements key name on the same table row as the inner-most elements values.)

36864's avatar

How about something likes this then:

//partials.group
@foreach($elements as $key => $element)
    @if($element instanceof Illuminate\Support\Collection)
      <tr class="depth-{{$depth}}">
        <td>{{$key}}</td>
      </tr>
        @include('partials.group', ['elements' => $element, 'depth' => $depth+1])
    @else
        @include('partials.leaf', ['key' => $key, 'element' => element, 'depth' => $depth])
    @endif 

@endforeach

//partials.leaf
<tr class="depth-{{$depth}}">
<th>{{$key}}</th>
<td>{{$element->property}}</td>
</tr>

should match the original example in your OP.

madsem's avatar

@36864 thanks for all you help man, I really appreciate that a lot :)

Now we're pretty much at the point when I started the thread, I tried something similar (again, yours def. cleaner and makes more sense) but sadly the end result is the same.

We're now back at the missing properties error stage:

Property [product_group] does not exist on this collection instance.

So it throws this error without me trying anywhere to explicitly accessing this property (which does exist, it loops that far on it's own)

36864's avatar

Post your current code, I'm assuming you didn't copy/paste my template verbatim.

madsem's avatar

@36864 yup, you're right. I also just figured out it was a mistake on my end, changed a variable name to try to make things clearer for me and forgot it lol

This is almost it, but still I can't get the metrics on the same row in the table.

Here is the complete code:

#reports.blade (this is where the parent table sits
# $depth = 0 here
...
<tbody>
    @foreach ($groups as $group)
        @include('partials.group', ['elements' => $group])
    @endforeach
    </tbody>
...
#partials.groups
@foreach($elements as $key => $element)
    @if($element instanceof Illuminate\Support\Collection)
        <tr>
            <th scope="row" colspan="12" class="alert-info pl-{{ $depth }}">
                {{$key}}
            </th>
        </tr>
        @include('partials.group', ['elements' => $element, 'depth' => $depth+1])
    @else
        @include('partials.leaf', ['key' => $key, 'element' => $element, 'depth' => $depth])
    @endif
@endforeach 
#partials.leafs
<tr>
    <th scope="row" class="pl-{{ $depth }}">
        {{$key}}
    </th>
    <td>{{ $element->views }}</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
</tr>

How the table looks like: Screen_Shot_2018_05_14_at_12_48_08_PM

madsem's avatar

@36864 this is how it's supposed to look like:

Screen_Shot_2018_05_14_at_12_53_14_PM

So the stats always on the same row as the final group in the collection

36864's avatar

That's gonna be difficult with your current data structure.

For this example, what you have under 'chrome' is a collection, but there's only one element in that collection.

The easy way out of this would be to change the way you build your data structure to ensure the final level is what you need it to be.

Basically, what you have is

['domain.com' =>
    ['store' =>
        ['chrome' =>
            [0 =>
                [(chrome data)]
            ]
        ],
        ['firefox' => 
            [0 => 
                [(firefox data)]
            ]
        ], (...)
    ], (...)
], (...)

and what you want to have is

['domain.com' =>
    ['store' =>
        ['chrome' =>
            [(chrome data)]
        ],
        ['firefox' =>
            [(firefox data)]
        ], (...)
    ],(...)
],(...)

For your current data structure to work, you'd have to be able to check if you're in the second-to-last level, which complicates things.

It may be easier to change the way you're building your data so it matches the second data structure Ive described here.

madsem's avatar

@36864 that makes a lot of sense, tbh I thought about it also but was unsure how the data should be structured, which you just told me :)

So this is how I build the data (and specifically using groupBy on the collection to achieve the grouped structure.

Without it I have one Collection per result row, which I thought would be way harder to deal with to achieve the needed table design?

$groups = DB::table('tracking_facts')
                  ->selectRaw('lander_dims.lander_group, sum(page_views) AS views, sum(visits) AS visits, sum(clicks) AS clicks, sum(conversions) AS conversions, sum(revenue) AS revenue')
                  ->when(! empty($groupBy), function ($groupings) use ($request) {
                      // if groupBy select fields were posted, we also have to select them them here
                      foreach ($request->get('groupBy') as $grouping) {
                          if ( ! empty($grouping)) {
                              $groupings->addSelect($grouping);

                              // get the first part of groupBy value, which is the table name
                              $tblname = explode('.', $grouping)[0];

                              // add joins for existing groupBy selections
                              if ($tblname != 'lander_dims') {
                                  $groupings->join($tblname, "tracking_facts.{$tblname}_id", '=', "{$tblname}.id");
                              }
                          }
                      }

                      return $groupings;
                  })
                  ->join('lander_dims', 'tracking_facts.lander_dims_id', '=', 'lander_dims.id')// always join lander dimensions table
                  ->where('lander_dims.lander_group', '=', $request->get('byGroup'))
                  ->when(! $request->has('withBots'), function ($q) {
                      return $q->where('tracking_facts.is_bot', '=', 0);
                  })
                  ->whereDate('tracking_facts.updated_at', '>=', Carbon::parse($fromDateTime))
                  ->whereDate('tracking_facts.updated_at', '<=', Carbon::parse($toDateTime))
                  ->when(! empty($groupBy), function ($q) use ($groupBy) {
                      return $q->groupBy($groupBy);
                  })
                  ->get();

        // group collection by selected groupBy fields
        if ( ! empty($groupBy)) {
            $groups = $groups->groupBy($groupBy);
        }

        $depth = 0;
    
        return view('reports', compact('landerGroups', 'groups', 'depth'));
36864's avatar

As a quick hack this might do the trick, but it's pretty ugly:

#partials.groups
@foreach($elements as $key => $element)
    @if($element instanceof Illuminate\Support\Collection && $element->first() instanceof Illuminate\Support\Collection)
        <tr>
            <th scope="row" colspan="12" class="alert-info pl-{{ $depth }}">
                {{$key}}
            </th>
        </tr>
        @include('partials.group', ['elements' => $element, 'depth' => $depth+1])
    @else
        @include('partials.leaf', ['key' => $key, 'element' => $element->first(), 'depth' => $depth])
    @endif
@endforeach 

#partials.leafs
<tr>
    <th scope="row" class="pl-{{ $depth }}">
        {{$key}}
    </th>
    <td>{{ $element->views }}</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
</tr>

EDIT: had tab open for a while before your reply.

I'm off to have lunch but I'll try and look through your query afterwards.

madsem's avatar

@36864 yeah you were right, this is almost it.

The only thing that is not correct is that now we always have the final group also as colspan row (empty) before the row with the stats.

Screen_Shot_2018_05_14_at_1_22_50_PM

And I also feel, while this comes close, it is very ugly and hard to extend :) So the goal should be to rewrite the code that generates the Collection.

I'm unsure where to go from here though tbh, as groupBy() in the query builder spits out one Collection per row. And when working with thousands of rows, or even tens of thousands and more this would become a memory nightmare I guess.

madsem's avatar

@36864 thanks man appreciate that :) Enjoy your lunch!

This is the $groupBy array I'm using to group the collection. Before the query I posted above.

// create $groupBy array for grouping query & collection
        $groupBy = [];
        if ($request->has('groupBy') && ! empty($request->get('groupBy')[0])) {
            foreach ($request->get('groupBy') as $grouping) {
                // explode groupBy and take second part to get column_name
                if ( ! empty($grouping)) {
                    $columnName = explode('.', $grouping)[1];
                    array_push($groupBy, $columnName);
                }
            }
        }
36864's avatar

The only thing that is not correct is that now we always have the final group also as colspan row (empty) before the row with the stats.

That's quite odd. This should only happen if you have multiple levels with the same keys.

I wrote up a quick test script to check my latest code and it seems to work fine:

//controller
  public function testTable(Request $request)
  {
    $elements = collect([
      'domain1.com' => collect([
        "v1"  => collect([
          "chrome"  => collect([
            0 => (object) [
              "product_group" => "group_1",
              "views" => "17",
              "visits" => "5",
              "clicks" => "19",
              "conversions" => "14",
              "revenue" => "12.51",
              "domain_name" => "domain1.com",
              "store_version" => "v1",
              "browser" => "chrome",
            ]
          ]),
        ]),
      ]),
    ]);

    return view('testtable')->with('elements', $elements);
    }



//testtable.blade.php
<table class="table">
  <thead>
    <tr>
      <th>test</th>
    </tr>
  </thead>
  <tbody>
    @include('partials.group', ['elements' => $elements, 'depth' => 0])
  </tbody>
</table>



//group.blade.php
@foreach($elements as $key => $element)
    @if($element instanceof Illuminate\Support\Collection && $element->first() instanceof Illuminate\Support\Collection)
        <tr>
            <th scope="row" colspan="12" class="alert-info pl-{{ $depth }}">
                {{$key}}
            </th>
        </tr>
        @include('partials.group', ['elements' => $element, 'depth' => $depth+1])
    @else
        @include('partials.leaf', ['key' => $key, 'element' => $element->first(), 'depth' => $depth])
    @endif
@endforeach 



//leaf.blade.php
<tr>
    <th scope="row" class="pl-{{ $depth }}">
        {{$key}}
    </th>
    <td>{{ $element->views }}</td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
</tr>

Output:

<table class="table">
    <thead>
        <tr>
            <th>test</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th scope="row" colspan="12" class="alert-info pl-0">
                domain1.com
            </th>
        </tr>
        <tr>
            <th scope="row" colspan="12" class="alert-info pl-1">
                v1
            </th>
        </tr>
        <tr>
            <th scope="row" class="pl-2">
                chrome
            </th>
            <td>17</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>

As or rebuilding your query, it would indeed be harder than I originally thought and I'm afraid I don't have the time to come up with an alternative for you at the moment. Sorry!

madsem's avatar

@36864 yeah sorry, when I wrote that that was the first version before you edited the comment :D

It works now exactly as your test code also. The problem is only due to all the "whacky" checks we have to do because of how the data is formatted, there are now errors when less than 2 groups are selected.

(Like I said, the grouping is also dynamic, can be anything from 1 -3 group select fields that are posted with a reporting request)

Currently I am trying to figure out how to flatten only the innermost array in the Collection.

As you are completely right, if the array wouldn't have the 0 indexed array, it would be way easier to show the data in the correct format without using all the ->first() methods etc (which also cause errors if there are only 1 or 2 groups set)

My first naive try:

$groups->transform(function ($item, $key) {
            if(is_array($item)) {
                return array_flatten($item);
            }
            return $item;
        });

Of course doesn't work :)

madsem's avatar

uhmmm no, when I think about it that wouldn't work either. Because I don't think it's guaranteed that the final Collection always only has one array element...

So I'm back to your last code snippet, which works but only with min 2 groups selected.

1 group selected:

"Call to undefined method stdClass::first()"

no group selected

"Call to a member function first() on string"

Honestly, I'm kind of at a point where I feel stupid lol :) Should this be so hard?

36864's avatar
36864
Best Answer
Level 13
public function flattenLastLevel($collection)
  {
    if($collection instanceof Illuminate\Support\Collection) {
      if($collection->first() instanceof Illuminate\Support\Collection) {
        return $collection->map([$this, 'flattenLastLevel']);
      }
      else {
        return $collection->first();
      }
    }

    return $collection;
  }

  public function testTable(Request $request)
  {
    $elements = collect([
      'domain1.com' => collect([
        "v1"  => collect([
          "chrome"  => collect([
            0 => (object) [
              "product_group" => "group_1",
              "views" => "17",
              "visits" => "5",
              "clicks" => "19",
              "conversions" => "14",
              "revenue" => "12.51",
              "domain_name" => "domain1.com",
              "store_version" => "v1",
              "browser" => "chrome",
            ]
          ]),
        ]),
      ]),
    ]);

    $flattened = $elements->map([$this, 'flattenLastLevel']);
    dump($flattened);
  }

Flattens the last level of a collection, still works with only one level.

1 like
36864's avatar

uhmmm no, when I think about it that wouldn't work either. Because I don't think it's guaranteed that the final Collection always only has one array element...

Well, what's supposed to happen in that case?

madsem's avatar

I'm not sure, I said that because I am unsure if there is a case where the final level would have multiple array elements or not.

Thanks a ton for the flattenLastLevel() method, really nice :) Will play around with that also, see if I can make it work that way.

Next

Please or to participate in this conversation.