Im attempting to try and take a recursive function and build a multidimential array out of it.
I can create a single array out of it but i dunno how to build multiple array levels based on if it has sub items or not.
its rather confusing.
here is the code im using (its part of a class)
function print_menu_tree($id = 0, $level=0, $data ='') {
$result = $this->get_children($id);
if($this->get_type($result[$x]["id"]) == 1) {
$level++;
} else {
$level = 0;
}
for ($x=0; $x<count($result); $x++) {
if($this->get_type($result[$x]["id"]) == 1) {
$sub = "Has Sub";
} else {
$sub = "";
}
$values = str_repeat("\t", $level-1);
$data []['title'] = $values."count=".$x." ".$level." ".$result[$x]["label"] . "[" . $result[$x]["id"] . "]".$sub." \n";
$data = $this->print_menu_tree($result[$x]["id"], $level, $data);
}
return $data;
}
Another way to explain what im doing is simply making a nested array. Im loosing my mind here ;-/
Thanks for any help