note 118016 added to function.is-dir
| From: | jonlulf at gmail dot com | Date: | Fri, 18 Sep 2015 14:26:38 +0000 |
| Subject: | note 118016 added to function.is-dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203811@lists.php.net to get a copy of this message | ||
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++;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 78.73.224.17
----
Manual Page -- http://php.net/manual/en/function.is-dir.php
Edit -- https://master.php.net/note/edit/118016
Del: integrated -- https://master.php.net/note/delete/118016/integrated
Del: useless -- https://master.php.net/note/delete/118016/useless
Del: bad code -- https://master.php.net/note/delete/118016/bad+code
Del: spam -- https://master.php.net/note/delete/118016/spam
Del: non-english -- https://master.php.net/note/delete/118016/non-english
Del: in docs -- https://master.php.net/note/delete/118016/in+docs
Del: other reasons-- https://master.php.net/note/delete/118016
Reject -- https://master.php.net/note/reject/118016
Search -- https://master.php.net/manage/user-notes.php