There is an array of the form:

0 => [ field1 = ..., field2 = ..., arr = [ 0 => [ field1 = ..., field2 = ... ], 1 => [ field1 = ..., field2 = ... ] ] ], 1 => [...], ... 

In short, the elements of a completely identical structure are recorded hierarchically. For some purposes it is convenient, but for others it is not, it would be more convenient to work with the "flat" option. There are any functions on php that allow in this case to “flatten” an array, losing its hierarchy.

Write your code no problem, but if there are ready-made solutions, I would like to know about them.


This is what should happen in the end:

 0 => [ field1 = ..., field2 = ..., ], 1 => [ field1 = ..., field2 = ..., ], 2 => [ field1 = ..., field2 = ..., ], ... 
  • Add the option that you want to see in the end, the essence of the problem is not completely clear - Let's say Pie
  • @ Let'ssayPie, updated the question. - nup
  • Hierarchy can be any length? - Let's say Pie
  • @ Let'ssayPie, the nesting level is only one, but the number of elements is unlimited. - nup 7:43 pm
  • And still. $ array [0] ['arr'] [0] ['field1'] and $ array [0] ['field1'] where should they end up and what is the difference between them? - MAX

0