Here is a snippet to create a site map of all html files in a folder:
<?php
if ($dh = opendir('./')) {
$files = array();
while (($file = readdir($dh)) !== false) {
if (substr($file, strlen($file) - 5) == '.html') {
array_push($files, $file);
}
}
closedir($dh);
}
sort($files);
echo "<ul>\n";
foreach ($files as $file) {
$title = Title($file);
echo "<li><a href=\"$file\" title=\"$title\">$title</a></li>\n";
}
echo "</ul>\n";
function Title($filename) {
$title = substr($filename, 0, strlen($filename) - 5);
$title = str_replace('-', ' ', $title);
$title = ucwords($title);
return $title;
}
?>