| @@ 45-57 (lines=13) @@ | ||
| 42 | * |
|
| 43 | * @param array $items |
|
| 44 | */ |
|
| 45 | public static function deepFlatten(array $items): array |
|
| 46 | { |
|
| 47 | $result = []; |
|
| 48 | foreach ($items as $item) { |
|
| 49 | if (!\is_array($item)) { |
|
| 50 | $result[] = $item; |
|
| 51 | } else { |
|
| 52 | array_push($result, ...self::deepFlatten($item)); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| 56 | return $result; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Returns a new array with n elements removed from the left. |
|
| @@ 103-115 (lines=13) @@ | ||
| 100 | * |
|
| 101 | * @param array $items |
|
| 102 | */ |
|
| 103 | public static function flatten(array $items): array |
|
| 104 | { |
|
| 105 | $result = []; |
|
| 106 | foreach ($items as $item) { |
|
| 107 | if (!\is_array($item)) { |
|
| 108 | $result[] = $item; |
|
| 109 | } else { |
|
| 110 | array_push($result, ...array_values($item)); |
|
| 111 | } |
|
| 112 | } |
|
| 113 | ||
| 114 | return $result; |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Groups the elements of an array based on the given function. |
|