this is a script i use a lot - it's for doing links automatically on my site, but you can take out those bits (like the "stripping the html" etc) if you dont need them.
<?php
$handle = opendir('./context') ;
// Open the directory
$file = readdir($handle);
$file = readdir($handle);
// The first two folders are . and .. - ignore these
while ($file = readdir($handle)) {
$file = ereg_replace(".html","",$file);
// Remove the .html from the filename
if ( substr($file,0,1) == "-") {
// Only print out the link if there is
// a - at the start
echo "<a href=";
echo "$file";
// Print out the link HTML code
echo ".html>";
// The following characters are changed
// when actually printing out the link text
// so spaces can be used etc.
$file = ereg_replace("-","",$file);
$file = ereg_replace(",","'",$file);
$file = ereg_replace("_"," ",$file);
$file = ereg_replace("~",",",$file);
echo "$file";
// Print the hyperlink text
echo "</a><br>";
// Close the <A> tag.
}
}
closedir($handle);?>