In reply to [EMAIL PROTECTED]:
> Return-Path: <[EMAIL PROTECTED]>
> Received: from toye.php.net (va.php.net [198.186.203.51])
> by cobalt1.intermedia.com.sg (8.10.2/8.10.2) with SMTP id f4FE59Z12111
> for <[EMAIL PROTECTED]>; Tue, 15 May 2001 22:05:09 +0800
> Received: (qmail 18619 invoked by uid 1013); 15 May 2001 14:07:42 -0000
> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> Precedence: bulk
> list-help: <mailto:[EMAIL PROTECTED]>
> list-unsubscribe: <mailto:[EMAIL PROTECTED]>
> list-post: <mailto:[EMAIL PROTECTED]>
> Delivered-To: mailing list [EMAIL PROTECTED]
> Received: (qmail 18613 invoked by uid 9); 15 May 2001 14:07:42 -0000
> To: [EMAIL PROTECTED]
> From: "Alessio Bernesco Lāvore" <[EMAIL PROTECTED]>
> Date: Tue, 15 May 2001 16:10:01 +0200
> Lines: 13
> Message-ID: <9drd7e$i5j$[EMAIL PROTECTED]>
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
> Subject: [PHP-WIN] HELP: Print directory structure.
> X-UIDL: _pi!!6+M"!']"#!:a&#!
> Could someone help me, please?
> I have to build a recursive function that print to video all the directories
> (and sub-directories and so on...) names presents in a specified
> sub-directory on the server.
> I can't handle that function, please, i'm in panic...
> Thanks,
> Alessio.
This simple and raw code should work fine:
<?
function parse_dir($dir,$level){
print $dir." (DIR)<BR>\n";
$dp=opendir($dir);
while (false!=($file=readdir($dp))){
if ($file!="." && $file!=".."){
if (is_dir($dir."/".$file)) parse_dir($dir."/".$file,$level+1);
else print $dir."/".$file."<BR>\n";
}
}
}
$start_dir="c:/root";
$level=1;
parse_dir($start_dir,$level);
?>
You could do some obvious modifications.
One impt thing to note is that the script might 'time out' if you are
listing a very huge list of dirs and files. To overcome this,
set_time_limit() might help. http://www.php.net/set_time_limit for
more info.
Hope that helps :)
Regards,
Keith Ng
_______________________________
Co-founder
K-Designs Incorporated
[EMAIL PROTECTED]
http://www.k-designs.com.sg/
--
PHP Windows 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]