isFile()) { $ext = strtolower(pathinfo($file->getFilename(), PATHINFO_EXTENSION)); if (in_array($ext, $allowed, true)) { $absPath = $file->getPathname(); $relPath = str_replace('\\', '/', substr($absPath, strlen(__DIR__) + 1)); $title = preg_replace('/[_\-]+/', ' ', pathinfo($file->getFilename(), PATHINFO_FILENAME)); $title = trim($title); $songs[] = [ 'title' => $title, 'url' => $relPath, 'name' => basename($relPath), 'ext' => $ext, 'size' => filesize($absPath), ]; } } } } usort($songs, fn($a,$b) => strcasecmp($a['title'], $b['title'])); ?>
/songs