PHPverse 2025

Voting

: max(eight, nine)?
(Example: nine)

The Note You're Voting On

jonlulf at gmail dot com
9 years ago
My solution to the problem that you must include the full path to make "is_dir" work properly as a complete example:

<? // findfiles.php - what is in directory "videoarchive"
$dir = 'images/videoarchive/'; // path from top
$files = scandir($dir);
$files_n = count($files);


$i=0;
while($i<=$files_n){
// "is_dir" only works from top directory, so append the $dir before the file
if (is_dir($dir.'/'.$files[$i])){
$MyFileType[$i] = "D" ; // D for Directory
} else{
$MyFileType[$i] = "F" ; // F for File
}
// print itemNo, itemType(D/F) and itemname
echo '<br>'.$i.'. '. $MyFileType[$i].'. ' .$files[$i] ;
$i++;
}
?>

<< Back to user notes page

To Top