mirror of
https://github.com/Codappix/search_core.git
synced 2024-12-26 04:36:10 +01:00
Daniel Siepmann
2d9062b6e3
* Do not add duplicate information from PHP to phpdoc. * Do not add useless comments like "this is a constructor of class x".
31 lines
820 B
PHP
31 lines
820 B
PHP
<?php
|
|
|
|
namespace Codappix\SearchCore\Utility;
|
|
|
|
/**
|
|
* Utility: Array
|
|
* @package Codappix\SearchCore\Utility
|
|
*/
|
|
class ArrayUtility
|
|
{
|
|
/**
|
|
* Recursively removes empty array elements.
|
|
*
|
|
* @see \TYPO3\CMS\Extbase\Utility\ArrayUtility::removeEmptyElementsRecursively Removed in TYPO3 v9
|
|
*/
|
|
public static function removeEmptyElementsRecursively(array $array): array
|
|
{
|
|
$result = $array;
|
|
foreach ($result as $key => $value) {
|
|
if (is_array($value)) {
|
|
$result[$key] = self::removeEmptyElementsRecursively($value);
|
|
if ($result[$key] === []) {
|
|
unset($result[$key]);
|
|
}
|
|
} elseif ($value === null) {
|
|
unset($result[$key]);
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
}
|