Conditions | 5 |
Paths | 5 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public static function removeEmptyElementsRecursively(array $array): array |
||
17 | { |
||
18 | $result = $array; |
||
19 | foreach ($result as $key => $value) { |
||
20 | if (is_array($value)) { |
||
21 | $result[$key] = self::removeEmptyElementsRecursively($value); |
||
22 | if ($result[$key] === []) { |
||
23 | unset($result[$key]); |
||
24 | } |
||
25 | } elseif ($value === null) { |
||
26 | unset($result[$key]); |
||
27 | } |
||
28 | } |
||
29 | return $result; |
||
30 | } |
||
32 |