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 = ..., ], ...