I have an array like this
$a = array(
'b' => array(
'two' => false,
'three' => '',
'four' => null,
'five' => array(
'fp' => null,
'kp' => null
),
'six' => array()
),
'c' => ' ',
'd' => null
);
I want to remove only null and empty keys from this n-level array. And finally I should get this:
$a = array(
'b' => array(
'two' => false
),
'c' => ' '
);
I have this function
public function ArrayCleaner($input) {
foreach ($input as &$value) {
if (is_array($value)) {
$value = ArrayCleaner($value);
}
}
return array_filter($input);
}
But, as array_filter states, it will also remove false value key (that I want to preserve). So what change I should make in my function to achieve the expected result?