note 10715 added to readdir
| From: | corbeau at iname dot com | Date: | Thu, 18 Jan 2001 19:00:33 +0000 |
| Subject: | note 10715 added to readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9935@lists.php.net to get a copy of this message | ||
SIMPLE SOLUTION:
I spent a while trying to figure out how the looping and recursion would work... then I just wrote
this.
The simplistic way to get files recursively:
$dir="/directory/";
$a =
find $dir -depth -type f -print;
$files = explode ("\n", $a);
Puts all the files into an array.
Do a basename() on each element to get the file name, and a dirname() to get the directory name.
Viola!
http://www.php.net/manual/en/function.readdir.php