This ought to do what you want:
<?php
function dir_print($dir) {
chdir($dir);
$dh = opendir($dir);
while($fname = readdir($dh)) {
if($fname!='.' && $fname!='..') {
if(is_dir($fname)) {
dir_print($dir.'/'.$fname);
} else {
echo "$dir/$fname<br>";
}
}
}
closedir($dh);
}
dir_print("/home/hmarq");
?>
Caveats:
It's unix style slashes --
Does no error checking -- perms in particular
Hank
On Mon, Nov 26, 2001 at 04:15:45PM +0100, Christoph Starkmann wrote:
> Ooops...
>
> I'm just ging mad about a function to recursively scan a directory tree.
> Maybe I'm just too stupid, maybe it's just because today is monday, but I
> don't get this ******** managed.
>
> Has anybody got a code sniplet the runs from $currentDir recursively through
> all directories, does something with all files found there and stops after
> returning to the starting directory?
>
> Phew... Would be great, I'm kind of in a hurry...
>
> Cheers,
>
> Kiko
>
> -----
> It's not a bug, it's a feature.
> christoph starkmann
> mailto:[EMAIL PROTECTED]
> http://www.fh-augsburg.de/~kiko
> ICQ: 100601600
> -----
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
Hank Marquardt <[EMAIL PROTECTED]>
http://web.yerpso.net
GPG Id: 2BB5E60C
Fingerprint: D807 61BC FD18 370A AC1D 3EDF 2BF9 8A2D 2BB5 E60C
*** Web Development: PHP, MySQL/PgSQL - Network Admin: Debian/FreeBSD
*** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild
*** Beginning PHP -- Starts January 7, 2002
*** See http://www.hwg.org/services/classes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]