Originariamente inviato da blues1976
Ciao, grazie della risposta ma a me interessava principalmente escludere i file che non voglio vengano visualizzati
come gia ti ho detto costruisci un array e confronti
Codice PHP:
<?php
// Note that !== did not exist until 4.0.0-RC2
$files=array("file1","file2","file3");
function eContenuto($array,$file_da_confrontare){
foreach($array as $val){
if($file_da_confrontare == $val){
return true;
}
}return false;
}
if ($handle = opendir('.')) {
echo "Directory handle: $handle\n";
echo "Files:\n";
$i=0;
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if(!eContenuto($files,$file)){
echo $i++." ";
echo "$file</br>";
}
}
echo "</td></tr></table>";
/* This is the WRONG way to loop over the directory. */
while ($file = readdir($handle)) {
echo "$file\n";
}
closedir($handle);
}
?>
ovviamente nell'array $files ci metti i file che non vuoi vedere