$da['id'])); if(!empty($childs)) { foreach($childs as &$child) { $grandchilds = pdo_fetchall('SELECT * FROM ' . tablename('core_menu') . ' WHERE pid = :pid ORDER BY is_system ASC, displayorder ASC, id ASC', array(':pid' => $child['id'])); if(!empty($grandchilds)) { foreach($grandchilds as &$grandchild) { $greatsons = pdo_fetchall('SELECT * FROM ' . tablename('core_menu') . ' WHERE pid = :pid ORDER BY is_system ASC, displayorder ASC, id ASC', array(':pid' => $grandchild['id'])); $grandchild['greatsons'] = $greatsons; } } $child['grandchild'] = $grandchilds; } $da['child'] = $childs; } } } return $data; }