a6april
12-06-2008, 10:25 PM
I am trying to display in a list format the contents of a specific directory. However I would like to exclude specific files for example:
.htaccess
error_log
another_file.html
some_sub_Directory.
Just having a hard time with the the and if else statements, I am assuming that is the way to go, if not please advise, here is the code I am working with:
#######################
<?php
$path = "/Directory Path/To/Folder";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
echo "$i. <a target=_blank href='$file'>$file</a><br />";
$i++;
}
}
closedir($dh);
?>
#########################
.htaccess
error_log
another_file.html
some_sub_Directory.
Just having a hard time with the the and if else statements, I am assuming that is the way to go, if not please advise, here is the code I am working with:
#######################
<?php
$path = "/Directory Path/To/Folder";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
echo "$i. <a target=_blank href='$file'>$file</a><br />";
$i++;
}
}
closedir($dh);
?>
#########################