Re: How can i print out the files in a directory?
| From: | Nitin | Date: | Fri, 17 Oct 2003 16:06:23 +0000 |
| Subject: | Re: How can i print out the files in a directory? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-166483@lists.php.net to get a copy of this message | ||
you can use simply
exec("ls -l 2>&1;", $output) : if on linux OR
exec("dir 2>&1;", $output) : if on windows
Enjoy
Nitin
----- Original Message -----
From: "Craig Lonsbury" <craig@topdraw.com>
To: "Bas" <bas_timmer49@hotmail.com>; <php-general@lists.php.net>
Sent: Friday, October 17, 2003 8:40 PM
Subject: RE: [PHP] How can i print out the files in a directory?
> This has been working for me...
> just pass the function the path to the directory you
> want the listing for.
>
> function getDirFiles($dirPath){
> if ($handle = opendir($dirPath)) {
> while (false !== ($file = readdir($handle))) {
> if ($file != "." && $file != "..") {
> $filesArr[] = trim($file);
> }
> }
> closedir($handle);
> }
> return $filesArr;
> }
>
> hth,
> Craig
>
> -----Original Message-----
> From: Bas [mailto:bas_timmer49@hotmail.com]
> Sent: October 17, 2003 6:42 AM
> To: php-general@lists.php.net
> Subject: [PHP] How can i print out the files in a directory?
>
>
> How can i print out all of the files in a directory?
>
> I want some output as this:
>
> index.php
> login.php
> image1.gif
> image2.jpg
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>