Page 1 of 1

trying to ignore one file within a list

Posted: Sun May 17, 2009 2:57 pm
by saulstokes
Hi, I'm using the php code below to list the contents of a folder. However, in that folder, I want to ignore one thing. In this case, it's the .htaccess. i don't want this to appear in this list or show up as a link. Would someone mind showing me the process for doing this? Essentially, I would like to modify the code below so that .htaccess will not show up.

Thank you,
Saul

.htaccess
accents
bassdrums
claps
crashes
hats
index.html
signnocker_bd.mp3
small pitched_bd.mp3
snares
toms


Code: Select all

 
<html>
<head><title>page</title>
</head>
<body>
<?php
$dir=opendir(".");
$files=array();
while (($file=readdir($dir)) !== false)
{
if ($file != "." and $file != ".." and $file != "index.php")
{
array_push($files, $file);
}
}
closedir($dir);
sort($files);
foreach ($files as $file)
print "<A href='$file'>$file</a>
<BR>"; 
?>
</body>
</html>
 

Re: trying to ignore one file within a list

Posted: Sun May 17, 2009 3:35 pm
by califdon
Please follow the rules of this forum and don't post PHP code like that without enclosing it in code tags, for readability.

Do you see how you are already excluding the "." and ".." and "index.php" file entries? Do exactly the same for ".htaccess".

Re: trying to ignore one file within a list

Posted: Sun May 17, 2009 3:44 pm
by saulstokes
Thank you and my apologies. I'm a noobie at this and don't really understand much of it.
s