function deepchildids($rows, $root_id) { static $childids = ''; $childs = findChild($rows, $root_id); if (empty($childs)) { return null; } foreach ($childs as $k => $v) { deepchildids($rows, $v['id']); $childids .= $v['id'] . ','; } return $childids; }
/** * Checks if node has another node as child * @param HTML_Node $child * @return bool */ function hasChild($child) { return (bool) findChild($child); }
function build_tree($root_id, $rows) { $childs = findChild($rows, $root_id); if (empty($childs)) { return null; } foreach ($childs as $k => $v) { $rescurTree = build_tree($v['id'], $rows); if (null != $rescurTree) { $childs[$k]['childs'] = $rescurTree; } } return $childs; }