<?php
use Illuminate\Support\Arr;
$array1 = [
1, 2,
[3, 4],
[5],
6, 7,
];
$array2 = [
'one' => 1,
'two' => 2,
[
'one' => 3,
'four' => 4,
],
'five' => 5,
];
$flatten1 = Arr::flatten($array1);
$flatten2 = Arr::flatten($array2);
dump($flatten1, $flatten2);
^ array:7 [
0 => 1
1 => 2
2 => 3
3 => 4
4 => 5
5 => 6
6 => 7
]
^ array:5 [
0 => 1
1 => 2
2 => 3
3 => 4
4 => 5
]