src/Helpers/DPDHelper.php
<?php
declare(strict_types=1);
namespace SergeevPasha\DPD\Helpers;
class DPDHelper
{
/**
* Remove null values from an array recursively
*
* @param array $haystack
*
* @return array
*/
public static function removeNullValues(array $haystack): array
{
foreach ($haystack as $key => $value) {
if (is_array($value)) {
$haystack[$key] = self::removeNullValues($haystack[$key]);
}
if (empty($haystack[$key]) && $haystack[$key] !== false) {
unset($haystack[$key]);
}
}
return $haystack;
}
}