note 42549 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:05:15 +0000
Subject: note 42549 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126539@lists.php.net to get a copy of this message
Note Submitter: jw5_feedback at comcast dot net ---- Ok you have seen a bunch of them recursive directory functions, but heres mine that loads them all into an array and emdeded arrays that contain all the file names. /*********************************************/ $main_dir = "downloads"; $A_main = Array($main_dir,); $start =& $A_main; $j = 0; function dir_recurse($dir,&$wia) { $i = 1; if($handle = opendir($dir)) { while(false !== ($file = readdir($handle))) { if($file != "." && $file != ".." ) { if(is_dir($dir."/".$file) == true) { $fullpath = $dir."/".$file; array_push($wia,array($file)); dir_recurse($fullpath,$wia[$i]); $i++; } else { $fullpath = $dir."/".$file; array_push($wia,$fullpath); $i++; } } } closedir($handle); } } dir_recurse($main_dir,$start); /********************************************/ wia stands for "where it's at" in relation to being in a directory.

« previous php.notes (#126539) next »