Código HTML:
[3] => Array ( [id] => 6 [__children] => Array ( [0] => Array ( [id] => 14 [estado] => X [__children] => Array ( ) ) [1] => Array ( [id] => 17 [estado] => A [__children] => Array ( ) ) )
Código PHP:
private function Recursive($input) {
$output = array();
$aux = array('id'=>'id','menu'=>'label','lft'=>'lft','rgt'=>'rgt','lvl'=>'lvl','root'=>'root','controller'=>'controller','action'=>'action','class'=>'class','active'=>'active','visible'=>'visible','estado'=>'estado','icono'=>'icono','uri'=>'uri','__children'=>'pages','module'=>'module');
foreach ($input as $key => $value) {
if (! is_array($value)) {
if($key == 'estado') {
if ( $value == 'X' ) {
//pues aqui debería devolver el array y realizar un unset
$output[$key] = $this->Recursive($value);
}
}
} else if($key === '__children' ){
if (!empty($value)){
$output['pages'] = $this->Recursive($value);
}
}else
$output[$key] = $this->Recursive($value);
}
return $output;
}