DaHax Posted August 18, 2010 Share Posted August 18, 2010 I am working on a little project for my site and I am trying to get this script to ignore the index.html file and the .htaccess file in there. I just want it to display all files like .zip, .rar, .tar, .gz, .gtar, .ace, ect... echo " <td width='70%'><select id='download'>"; echo " <option value=''>None</option>"; if ($handle = opendir("./modules/Downloads/files")) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo " <option value='".$file."'>".$file."</option>"; } } closedir($handle); } echo " </td>\n"; Link to comment https://forums.phpfreaks.com/topic/211087-how-to-make-this-ignore-certian-files/ Share on other sites More sharing options...
wildteen88 Posted August 18, 2010 Share Posted August 18, 2010 Change this line if ($file != "." && $file != "..") { to if (!in_array($file, $filesToIgnore)) { Now before the while() loop define an array of files you want your script to ignore $filesToIgnore = array('.', '..', '.htaccess', 'index.html'); Link to comment https://forums.phpfreaks.com/topic/211087-how-to-make-this-ignore-certian-files/#findComment-1100828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.