function addChildren($groups, $query) { $children = array(); foreach ($groups as $details) { if (isset($details["group"]) && $details["group"] == $query) { $key = array_push($children, $details); $children[$key - 1]["children"] = addChildren($groups, $details["id"]); } } return $children; }
function addChildren($title) { global $depth; $depth++; for ($i = 1; $i <= 5; $i++) { $t = $title . '.' . $i; echo "{$t}\n"; if ($depth < 3) { addChildren($t); } } $depth--; }
function addChildren($title) { global $depth, $cnt; $depth++; for ($i = 1; $i <= 5; $i++) { $t = $title . '.' . $i; $cnt++; echo "<div dojoType='TreeNodeV3' title='{$t}' widgetId='{$t}'>\n"; if ($depth < 3 && $cnt <= 100) { addChildren($t); } echo "</div>\n"; } $depth--; }
function addChildren($set, $link) { $url = $set->addChild("url"); $url->addChild("loc", URL . "/" . $link['loc']); if (isset($link['changefreq'])) { $url->addChild("changefreq", $link['changefreq']); } if (isset($link['lastmod'])) { $url->addChild("lastmod", $link['lastmod']->format("Y-m-d")); } if (isset($link['children'])) { foreach ($link['children'] as $child) { addChildren($set, $child); } } }
$menu_arr = array(); while ($row = mysql_fetch_assoc($result)) { $menu_arr[$row['Id']] = array('id' => $row['Id'], 'lp' => $row['position'], 'name' => $row['name'], 'path' => $row['path'], 'action' => $row['action'], 'hasChildren' => (int) $row['slave'] == 0 ? true : false, 'parentId' => (int) $row['ownerEl'], 'class' => $row['class']); } //echo '<pre>'.print_r($menu_arr, 1).'</pre>'; exit; foreach ($menu_arr as $key => $item) { if ($item['parentId'] != 0 && $item['hasChildren'] == false) { $parentId = $item['parentId']; addChild($menu_arr, $parentId, $item); unset($menu_arr[$key]); } } //echo '<pre>'.print_r($menu_arr, 1).'</pre><hr/>'; foreach ($menu_arr as $key => $item) { if ($item['parentId'] == 0 && $item['hasChildren'] == true) { addChildren($menu_arr, $item['id'], $key); } } //echo '<pre>'.print_r($menu_arr, 1).'</pre>'; exit; function addChild(&$menu_arr, $parentId, $child) { foreach ($menu_arr as $key => $item) { if ($item['id'] == $parentId && $item['hasChildren'] != false) { //$menu_arr[$key]['children'][$child['id']] = $child; $menu_arr[$key]['children'][$child['lp']] = $child; } } } function addChildren(&$menu_arr, $id, $idx) { foreach ($menu_arr as $key => $item) {