[PHP] Re: code to see files in directories

2001-08-08 Thread Henrik Hansen

[EMAIL PROTECTED] (Eduardo Kokubo) wrote:

 > I think I saw a code to list the files, subdirectories and the files
 > in the subdirectories of a simple directory in this list some time
 > ago, but I didn't save it. Considering the quantitie of messages in
 > this list, It's quite dificult to find this specific code, so ask the
 > person who did it or someone else to write this code again.
>
 > I'm using this one:
>
 > $publico = ftp_nlist ($servidor, "public_html/publico");
 > $cont = 0;
 > while ($publico[$cont]){
 >  print "$publico[$cont]";
 >  $cont++;}
>
 > This code doesn't show the files in the subdirectories and it requires
 > ftp connection. Not very efficient.
>
 > Thanks in advance.
>
 > Is there a problem if I just write "thanks in advance"??? It's easier
 > then writting back to thanks everybody :)
>

is this what your looking for?

function getDirContents($slashdir) {
$dh = opendir($slashdir);

while (($file = readdir ($dh))) {
if (is_dir($slashdir . $file) && $file != "." && $file != "..") {
getDirContents ($slashdir . $file . "/");
} else if ($file != "." && $file != "..") {
echo $file . "";
}
}
closedir($dh);
}

getDirContents("/test/");

-- 
Henrik Hansen

-- 
PHP General 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]




[PHP] Re: code to see files in directories

2001-08-18 Thread Sid

Try this -- shorter. I only tested it out in Win(32)though

At 03:00 PM 8/8/01 +0200, you wrote:
>[EMAIL PROTECTED] (Eduardo Kokubo) wrote:
>
>  > I think I saw a code to list the files, subdirectories and the files
>  > in the subdirectories of a simple directory in this list some time
>  > ago, but I didn't save it. Considering the quantitie of messages in
>  > this list, It's quite dificult to find this specific code, so ask the
>  > person who did it or someone else to write this code again.
> >
>  > I'm using this one:
> >
>  > $publico = ftp_nlist ($servidor, "public_html/publico");
>  > $cont = 0;
>  > while ($publico[$cont]){
>  >  print "$publico[$cont]";
>  >  $cont++;}
> >
>  > This code doesn't show the files in the subdirectories and it requires
>  > ftp connection. Not very efficient.
> >
>  > Thanks in advance.
> >
>  > Is there a problem if I just write "thanks in advance"??? It's easier
>  > then writting back to thanks everybody :)
> >
>
>is this what your looking for?
>
>function getDirContents($slashdir) {
> $dh = opendir($slashdir);
>
> while (($file = readdir ($dh))) {
> if (is_dir($slashdir . $file) && $file != "." && $file != "..") {
> getDirContents ($slashdir . $file . "/");
> } else if ($file != "." && $file != "..") {
> echo $file . "";
> }
> }
> closedir($dh);
>}
>
>getDirContents("/test/");
>
>--
>Henrik Hansen
>
>--
>PHP General 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]


-- 
PHP General 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]