Re: Recursive directory scan

From: Date: Mon, 26 Nov 2001 14:25:33 +0000
Subject: Re: Recursive directory scan
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75724@lists.php.net to get a copy of this message
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:kiko@nfq.de > http://www.fh-augsburg.de/~kiko > ICQ: 100601600 > ----- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > -- Hank Marquardt <hank@yerpso.net> 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

« previous php.general (#75724) next »