method removeEmpty documentation in bbn\X
Returns an object or an array cleaned of all empty values.
function($arr, $remove_space = false)
{
$isAssoc = X::isAssoc($arr);
foreach ($arr as $k => $v) {
if (\is_object($arr)) {
if (\is_array($v) || \is_object($v)) {
$arr->$k = self::removeEmpty($v, $remove_space);
}
else {
if (empty($v)) {
if (isset($arr->$k)) {
unset($arr->$k);
}
}
else {
$arr->$k = $v;
}
}
}
else{
if (\is_array($v) || \is_object($v)) {
$arr[$k] = self::removeEmpty($v, $remove_space);
}
elseif ($remove_space && is_string($v)) {
$arr[$k] = trim($arr[$k]);
}
if (empty($arr[$k])) {
unset($arr[$k]);
}
}
}
if (!$isAssoc) {
$arr = array_values($arr);
}
return $arr;
}
Returns an object or an array cleaned of all empty values. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions