note 89589 modified in function.opendir by danbrown
| From: | danbrown@php.net | Date: | Fri, 17 Apr 2009 14:46:28 +0000 |
| Subject: | note 89589 modified in function.opendir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153434@lists.php.net to get a copy of this message | ||
Simple way to read all regular files in a directory. (Excluding contained directories, symbolic
links.. etc.)
<?php
$dir = "../files";
if($handle = opendir($dir))
{
while($file = readdir($handle))
{
clearstatcache();
if(is_file($dir.'/'.$file))
echo $file;
}
closedir($handle);
}
?>
[NOTE BY danbrown AT php DOT net: Contains a bug fix submitted by (php1602 AT mail DOT ru) on
17-APR-09.]
--was--
Simple way to read all regular files in a directory. (Excluding contained directories, symbolic
links.. etc.)
<?php
$dir = "../files";
if($handle = opendir($dir))
{
while($file = readdir($handle))
{
clearstatcache();
if(is_file($dir.$file))
echo $file;
}
closedir($handle);
}
?>
http://php.net/manual/en/function.opendir.php