Commit 00f0beb9 authored by Oana-Eliza Alexa's avatar Oana-Eliza Alexa
Browse files

use maps

1 merge request!75Draft: Resolve "Redesign Mail"
Showing with 8 additions and 18 deletions
+8 -18
...@@ -13,20 +13,12 @@ class Utils ...@@ -13,20 +13,12 @@ class Utils
*/ */
public static function recursiveArrayFilter (array $array): array public static function recursiveArrayFilter (array $array): array
{ {
// First filter the array for non-empty elements return array_filter($array, function ($item) {
$filtered = array_filter($array, function ($item) { if (is_array($item)) {
if (is_array($item)) { $item = self::recursiveArrayFilter($item);
// Recursively filter the sub-array }
$item = self::recursiveArrayFilter($item);
// Only retain non-empty arrays
return !empty($item);
} else {
// Retain non-empty scalar values
return !empty($item); return !empty($item);
}
}); });
return $filtered;
} }
/** /**
...@@ -40,12 +32,10 @@ class Utils ...@@ -40,12 +32,10 @@ class Utils
{ {
$matching = []; $matching = [];
if (!empty($elements)) { foreach ($elements as $element) {
foreach ($elements as $element) { foreach ($keys as $key) {
foreach ($keys as $key) { if (!empty($element) && array_key_exists($key, $element)) {
if (!empty($element) && array_key_exists($key, $element)) { $matching[] = $key;
$matching[] = $key;
}
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment