mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Miglioramento dati FE per righe di fattura
This commit is contained in:
36
lib/util.php
36
lib/util.php
@@ -45,6 +45,42 @@ if (!function_exists('array_clean')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('array_deep_clean')) {
|
||||
/**
|
||||
* Pulisce i contenuti vuoti di un array.
|
||||
*
|
||||
* @param $array
|
||||
*
|
||||
* @since 2.4.11
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function array_deep_clean($input)
|
||||
{
|
||||
// If it is an element, then just return it
|
||||
if (!is_array($input)) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
$non_empty_items = [];
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
// Ignore empty cells
|
||||
if ($value) {
|
||||
$cleaned = array_deep_clean($value);
|
||||
|
||||
// Use recursion to evaluate cells
|
||||
if (!empty($cleaned)) {
|
||||
$non_empty_items[$key] = $cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Finally return the array without empty items
|
||||
return $non_empty_items;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('starts_with')) {
|
||||
/**
|
||||
* Check if a string starts with the given string.
|
||||
|
Reference in New Issue
Block a user