note 59783 modified in class.dir by bjori
| From: | bjori@php.net | Date: | Fri, 14 Apr 2006 22:12:07 +0000 |
| Subject: | note 59783 modified in class.dir by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108114@lists.php.net to get a copy of this message | ||
there is a little bug in pervious post. I've changed it a bit:
<?php
function read_dir($dir) {
$array = array();
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if($entry!='.' && $entry!='..') {
$entry = $dir.'/'.$entry;
if(is_dir($entry)) {
$array = array_merge($array, read_dir($entry));
} else {
$array[] = $entry;
}
}
}
$d->close();
return $array;
}
?>
now it works perfect ;-)
--was--
there is a little bug in pervious post. I've changed it a bit:
function read_dir($dir) {
$array = array();
$d = dir($dir);
while (false !== ($entry = $d->read())) {
if($entry!='.' && $entry!='..') {
$entry = $dir.'/'.$entry;
if(is_dir($entry)) {
$array = array_merge($array, read_dir($entry));
} else {
$array[] = $entry;
}
}
}
$d->close();
return $array;
}
now it works perfect ;-)
http://php.net/manual/en/class.dir.php