All pastes #443152 Raw Edit

mapito

public php v1 · immutable
·published 2007-04-16 17:32 UTC
rendered paste body
  <?php  	 function recur_dir($dir)  	 {  	     $dirlist = opendir($dir);  	     while ($file = readdir ($dirlist))  	     {  	         if ($file != '.' && $file != '..')  	         {  	             $newpath = $dir.'/'.$file; 	             $level = explode('/',$newpath);  	             if (is_dir($newpath))  	             { 	                 $mod_array[] = array(  	                         'level'=>count($level)-1, 	                         'path'=>$newpath,  	                         'name'=>end($level),  	                         'kind'=>'dir',	                         'mod_time'=>filemtime($newpath),                         'content'=>recur_dir($newpath));  	             }else{ 	                 $mod_array[] = array( 	                         'level'=>count($level)-1, 	                         'path'=>$newpath, 	                         'name'=>end($level),  	                         'kind'=>'file',  	                         'mod_time'=>filemtime($newpath),  	                         'size'=>filesize($newpath));  	            }  	         } 	     } 	     closedir($dirlist);  	     return $mod_array; 	 } 	 echo '<pre>';	 print_r(recur_dir('.')); 	 echo '</pre>';?>