1, 'parent_id' => 0, 'name' => 'Software developer'), array('id' => 2, 'parent_id' => 1, 'name' => 'Desktop app developer'), array('id' => 3, 'parent_id' => 1, 'name' => 'Mobil app developer'), array('id' => 4, 'parent_id' => 1, 'name' => 'Web app developer'), array('id' => 5, 'parent_id' => 4, 'name' => 'PHP'), array('id' => 6, 'parent_id' => 2, 'name' => 'C++'), array('id' => 7, 'parent_id' => 4, 'name' => 'Python'), array('id' => 8, 'parent_id' => 2, 'name' => 'Java SE'), array('id' => 9, 'parent_id' => 2, 'name' => 'C#'), array('id' => 10, 'parent_id' => 3, 'name' => 'Swift'), array('id' => 11, 'parent_id' => 3, 'name' => 'Java Android'), ); function buildTree($menuler, $parentId = 0) { $tree = $menuler(); foreach ($menuler as $element) { if ($element[‘parent_id‘] == $parentId) { $children = buildTree($menuler, $element[‘id‘]); if ($children) { $element[‘children‘] = $children; } $tree[] = $element; } } return $tree; } $tree = buildTree($categories); //------------------------ ini_set(‘xdebug.var_display_max_depth‘, ‘5‘); var_dump($tree[0]); /* Burada söylenmek İstenen Aşagıdaki gibi bir şemadır. Üst Menü Software developer Desktop app developer C++ Java SE C# Mobil app developer Swift Java Android Web app developer PHP Python */ ?>