anolan13 Posted August 3, 2007 Share Posted August 3, 2007 Hello again, Right now I have a page that displays all files in a certain directory, makes them a link, and then theres checkboxes. Works great...only thing is I need it to leave out a certain file (process.php) How do I do this? This is my code... $handle=opendir("files/"); while (($file = readdir($handle))!==false) { echo "<li><a href='http://www.mywebsite.com/files/$file'>$file</a></li> <br>"; echo "<input type='checkbox' name='delete[]' value='$file'>"; } closedir($handle); echo "</ol>\n"; echo "<input type='submit' value='Delete'>\n"; echo "</form\n"; Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/63252-solved-leaving-certain-file-out-of-a-show-all-file-loop/ Share on other sites More sharing options...
cooldude832 Posted August 4, 2007 Share Posted August 4, 2007 try making an array of the files you wish not to display then in the loop say <?php $badfiles = array("file1.html","file2.php"); if(!in_array($file,$badfiles)){//display} ?> Quote Link to comment https://forums.phpfreaks.com/topic/63252-solved-leaving-certain-file-out-of-a-show-all-file-loop/#findComment-315272 Share on other sites More sharing options...
teng84 Posted August 4, 2007 Share Posted August 4, 2007 $arr=array('va.php'.......); //sample while (($file = readdir($handle))!==false) { if (in_array($file,$arr)){ continue; } echo "<li><a href='http://www.mywebsite.com/files/$file'>$file</a></li> <br>"; echo "<input type='checkbox' name='delete[]' value='$file'>"; } escape the unwanted file!!!! Quote Link to comment https://forums.phpfreaks.com/topic/63252-solved-leaving-certain-file-out-of-a-show-all-file-loop/#findComment-315280 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.