PHP: Find depth of current array in recursive function -
is there way can current depth of array? far, had no luck this..
my code:
use app\components\treeview; use app\models\kategorije; $tree = treeview::getmenu(); function recursion($stablo,&$indent) { $indent++; // try depth of current array foreach ($stablo $value) { foreach ($value $key => $value) { $indent_str = str_repeat("-", $indent); echo $indent.$value['label'].'<br>'; if (!empty($value['items'])) { recursion($value['items'],$indent); } }; } } $indent = 0; recursion($tree,$indent);
i need depth indentation...
Comments
Post a Comment