Voting

: five plus one?
(Example: nine)

The Note You're Voting On

NerdyDork
18 years ago
Here is a snippet to create a site map of all html files in a folder:

<?php
// read all html file in the current directory
if ($dh = opendir('./')) {
$files = array();
while ((
$file = readdir($dh)) !== false) {
if (
substr($file, strlen($file) - 5) == '.html') {
array_push($files, $file);
}
}
closedir($dh);
}

// Sort the files and display
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 to get a human readable title from the filename
function Title($filename) {
$title = substr($filename, 0, strlen($filename) - 5);
$title = str_replace('-', ' ', $title);
$title = ucwords($title);
return
$title;
}
?>

<< Back to user notes page

To Top