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

use maps

1 merge request!75Draft: Resolve "Redesign Mail"
This commit is part of merge request !75. Comments created here will be created in the context of that merge request.
Showing with 8 additions and 18 deletions
+8 -18
......@@ -13,20 +13,12 @@ class Utils
*/
public static function recursiveArrayFilter (array $array): array
{
// First filter the array for non-empty elements
$filtered = array_filter($array, function ($item) {
if (is_array($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 array_filter($array, function ($item) {
if (is_array($item)) {
$item = self::recursiveArrayFilter($item);
}
return !empty($item);
}
});
return $filtered;
}
/**
......@@ -40,12 +32,10 @@ class Utils
{
$matching = [];
if (!empty($elements)) {
foreach ($elements as $element) {
foreach ($keys as $key) {
if (!empty($element) && array_key_exists($key, $element)) {
$matching[] = $key;
}
foreach ($elements as $element) {
foreach ($keys as $key) {
if (!empty($element) && array_key_exists($key, $element)) {
$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