Please, someone ca help me with that?
I want to unset the parent array key if any value inside of that array is null;
e.g.
array
(
0 => array
(
'type' => 'Main'
'phone' => '11 555-1423'
'foo' => array(
0 => (
'bar' => ''
)
)
)
1 => array
(
'type' => 'Personal'
'phone' => ''
'foo' => array()
)
)
In this case I want to unset [0][foo] and [1].
I think this is exactly what you want
function fclear(&$arr, $del){
foreach($arr as $key=>&$val){
if($val == '')
return true;
if(is_array($val)){
$del = fclear($val, false);
if($del == true)
unset($arr[$key]);
}
}
}
fclear($myarr,false);
you can look at the Code Sample, run it and see result.