02. juni 2002 - 00:59Der er
3 kommentarer og 1 løsning
Dir listing
Jeg skal have php til at liste alle dir under et andet dir. Altså fx. sætter man startdir til "c:/winnt/" og så skal jeg bruge en liste over alle dirs (kun dirs, ingen filer) under det dir + der skal stå hvor mange MB der er i hvert dir og hvor mange filer...hele skidtet skulle gerne give output ala :
/dir/subdir/|35|400|2002-06-02 ^ ^ ^ ^ Dir Files MB Date
Efter ti år i London, Madrid, Paris og Utrecht kommer Sabios AI-fokuserede program af arrangementer om kundeoplevelser, ‘Disrupt’, for første gang til Danmark.
function RecurseDir($basedir, $AllDirectories=array()) { #Create array for current directories contents $ThisDir=array(); #switch to the directory we wish to scan chdir($basedir); $current=getcwd(); #open current directory for reading $handle=opendir("."); while ($file = readdir($handle)) { #Don't add special directories '..' or '.' to the list if (($file!='..') & ($file!='.')) { if (is_dir($file)) { #build an array of contents for this directory array_push($ThisDir,$current.'/'.$file); } } } closedir($handle); #Loop through each directory, run RecurseDir function on each one foreach ($ThisDir as $key=>$var) { array_push($AllDirectories, $var); $AllDirectories=RecurseDir($var, $AllDirectories); } #make sure we go back to our origin chdir($basedir); return $AllDirectories; }
function RecurseDir($basedir, $AllDirectories=array()) { #Create array for current directories contents $ThisDir=array(); #switch to the directory we wish to scan chdir($basedir); $current=getcwd(); #open current directory for reading $handle=opendir("."); while ($file = readdir($handle)) { #Don't add special directories '..' or '.' to the list if (($file!='..') & ($file!='.')) { if (is_dir($file)) { #build an array of contents for this directory array_push($ThisDir,$current.'\\'.$file); } } } closedir($handle); #Loop through each directory, run RecurseDir function on each one foreach ($ThisDir as $key=>$var) { array_push($AllDirectories, $var); $AllDirectories=RecurseDir($var, $AllDirectories); } #make sure we go back to our origin chdir($basedir); return $AllDirectories; }
function RecurseDir($basedir, $AllDirectories=array()) { #Create array for current directories contents $ThisDir=array(); #switch to the directory we wish to scan chdir($basedir); $current=getcwd(); #open current directory for reading $handle=opendir("."); while ($file = readdir($handle)) { #Don't add special directories '..' or '.' to the list if (($file!='..') & ($file!='.')) { if (is_dir($file)) { #build an array of contents for this directory array_push($ThisDir,$current.'\\'.$file); } } } closedir($handle); #Loop through each directory, run RecurseDir function on each one foreach ($ThisDir as $key=>$var) { array_push($AllDirectories, $var); $AllDirectories=RecurseDir($var, $AllDirectories); } #make sure we go back to our origin chdir($basedir); return $AllDirectories; }
function subfiles virker ikke helt fordi når den tjekker om $file er en fil eller et dir så mangler der lige at skrives $dir."\\" foran ;) men dette funker nu ! takker for hjælpen
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.