$f, 'path' => '/' . $rel]; } } } return $files; } $allFiles = scanAll('/opt/wevads/public', '', $excludeDirs, $excludeFiles); usort($allFiles, fn($a,$b) => strcmp($a['name'], $b['name'])); // Parse actual menu.html to get real structure function parseMenu($file) { $html = file_get_contents($file); $menu = []; // Remove comments $html = preg_replace('//s', '', $html); // Split by nav-toggle to get each parent section $parts = preg_split('/(]*nav-toggle[^>]*>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE); for ($i = 1; $i < count($parts); $i += 2) { if (!isset($parts[$i+1])) continue; $section = $parts[$i] . $parts[$i+1]; // Get parent title if (preg_match('/]*>([^<]+)/', $section, $pm)) { $parentTitle = trim($pm[1]); // Get sub-menu section $children = []; if (preg_match('/