$children) { $tree = array_merge($tree, $this->searchChildren($children, $root)); } $treeView = '
'; $treeView .= ''; $treeView .= ''; return $treeView; } private function searchChildren(array $folders, string $root): array { $tree = []; $tree[$root] = []; foreach ($folders as $folder) { $folder = trim(str_replace($root, '', $folder), '/\\'); if (empty($folder)) { continue; } $pathParts = explode('/', $folder); $variable = &$tree[$root]; foreach ($pathParts as $pathPart) { if (empty($variable[$pathPart])) { $variable[$pathPart] = []; } $variable = &$variable[$pathPart]; } } return $tree; } private function displayTree(array $tree, string $pathValue, string $path = ''): string { if (empty($tree)) { return ''; } $results = ''; return $results; } }