Log in

View Full Version : How to exclude a file from being in the listed dir files ?



arsenalbates
02-17-2011, 05:38 PM
I have set-up a script to list all the files on a folder. however as the script file is also in the same dir it is listing that too. How would i be able to filter out items from being listed ?:confused:

Schmoopy
02-17-2011, 07:56 PM
Depending on how you're doing it, you can just do something like:



<?php
foreach($files as $file) {

if($file != 'SCRIPT_NAME.php') {
// Do whatever
}

}
?>


You could probably use the $_SERVER variable to get this, but as long as you don't mind hard coding it, it's all good.

arsenalbates
02-18-2011, 05:29 PM
Thanks