Попробуйте это:
<code>function visibleCheck($test) {
$result = array();
foreach($test as $key => $value) {
if(isset($value['durum']) && $value['durum'] != 0) {
if(isset($value['children'])) {
$value['children']= visibleCheck($value['children']);
}
$result[$key] = $value;
}
}
return $result;
}
$test = array();
$test[0] = array();
$test[1] = array();
$test[2] = array();
$test[3] = array();
$test[4] = array();
$test[0]["durum"]=0;
$test[1]["durum"]=1;
$test[2]["durum"]=1;
$test[3]["durum"]=0;
$test[4]["durum"]=1;
$test[0]["children"]= array();
$test[1]["children"]= array(
0=> array(
'durum'=>1,
'some'=>'some more',
'children'=>array(
0=>array(
'durum'=>0,
'some'=>'some more',
'children'=>array(
0=>array(),
1=>array()
)
),
1=>array(
'durum'=>1,
'some'=>'some more',
'children'=>array(
0=>array(),
1=>array()
)
),
2=>array(
'durum'=>1,
'some'=>'some more',
'children'=>array(
0=>array(
0=>array(
'durum'=>1,
'some'=>'some more',
'children'=>array(
0=>array(),
1=>array()
)
),
1=>array(
'durum'=>0,
'some'=>'some more',
'children'=>array(
0=>array(),
1=>array()
)
),
),
1=>array()
)
),
),
),
1=> array(
'durum'=>0,
'some'=>'some more',
'children'=>array(
0=>array(
'durum'=>0,
'some'=>'some more',
'children'=>array(
0=>array(),
1=>array()
)
),
),
)
);
$test[2]["children"]= array();
$test[3]["children"]= array();
$test[4]["children"]= array();
echo "Before: <pre>";
echo print_r($test);
echo "
После
";
echo print_r(visibleCheck($test));
</code>