I've never ever touched PHP, so I'm sure I've done this the least efficient way possible, however it works, except for one slight "problem"; I would like to print the directories in alphabetic order. This has proven to be quite difficult for “PHP-challenged” (me), could anyone please help me out?
(The script below is pretty much a cut-paste from the various PHP-man pages with some slight modifications🙂
<?php
//define the path as relative
$path = "/";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
//running the while loop
$dir_handle=opendir('.');
while (false!==($file = readdir($dir_handle))) {
if ($file != "." && $file != ".." && $file != "index.php~" && $file != "index.php" ) {
echo "
<div align=center>
<TABLE width=80% border=1 bordercolor=#999999 bgcolor=#aaaaaa>
<TR>
<TD width=95 valign=top>";}
if ($file != "." && $file != ".." && $file != "index.php~" && $file != "index.php") {
echo "<img src=$file/$file.jpg>
</td>
<TD valign=top>";}
if ($file != "." && $file != ".." && $file != "index.php~" && $file != "index.php") {
readfile("$file/$file.txt");}
echo "</TD>
</tr>
</TABLE>
<br>
</div>";
}
//closing the directory
closedir($dir_handle);
?>
Thanks in advance!