How to convert array to treeview in php
Below is my array
Array
(
[0] => Array
(
[efi] => Array
(
)
)
[1] => Array
(
[grub] => Array
(
[0] => Array
(
[fonts] => Array
(
)
)
[1] => Array
(
[i386-pc] => Array
(
)
)
[2] => Array
(
[locale] => Array
(
)
)
[3] => Array
(
[x86_64-efi] => Array
(
)
)
)
)
)
I want output as treeview
efi
grub
and under grub I want
fonts
i386-pc
locale
x86_64-efi
I have used below code for same
function generateTreeMenu($dir_array, $parent = 0, $limit=0){
if($limit > 1000) return '';
$tree = '';
$tree = '<ul>';
for($i=0, $ni=count($dir_array); $i < $ni; $i++){
if($dir_array[$i]['parent_id'] == $parent){
$tree .= '<li><a>';
$tree .= $dir_array[$i]['title'].'</a>';
$tree .= generatePageTree($dir_array, $dir_array[$i]['id'], $limit++);
$tree .= '</li>';
}
}
$tree .= '</ul>';
return $tree;
}
generateTreeMenu($dir_array);
it show warning Undefined property: stdClass::$parent_id in