function getchilds($id, $parents, $ids = array()) { if (isset($parents[$id])) { foreach ($parents[$id] as $v) { $ids[$v] = $v; $ids += getchilds($v, $parents, $ids); } } return $ids; }
function getchilds($all, $cid) { if (!empty($all[$cid]) && is_array($all[$cid])) { foreach ($all[$cid] as $cc) { $arr[$cc] = getchilds($all, $cc); } return $arr; } else { return false; } }