Re: Re: [PHP] Directory & Array
| From: | Nathan Purciful | Date: | Thu, 06 Jul 2000 02:16:14 +0000 |
| Subject: | Re: Re: [PHP] Directory & Array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5145@lists.php.net to get a copy of this message | ||
This isnt working either
<?php
$dir = opendir('.') or die('Could not open dir.');
while ($file = readdir($dir)){
$files[] = $file;
}
closedir($dir);
sort($files);
reset($files);
while (list($k, $v) = each($files)){
echo $v, "<BR>\n";
}
?>
OutPut:
.
..
.htaccess
ImageLibrary
New Folder
centralokhog
corporate
devzone
dir.php
entrance
index.php
services
webexplorer10rc1
----- Original Message -----
From: Richard Lynch <richard@zend.com>
To: <php-general@lists.php.net>
Sent: Wednesday, July 05, 2000 8:09 PM
Subject: Re: [PHP] Directory & Array
> In article <20000705130504.87530.qmail@hotmail.com>, npurciful@hotmail.com
> ("Nathan Purciful") wrote:
>
> > Could someone please show me how to load a directory into array and
print it
> > in alphabetic order?
>
> Untested:
>
> <?php
> $dir = opendir('/path/to/your/dir') or die('Could not open dir.');
> while ($file = readdir($dir)){
> $files[] = $file;
> }
> closedir($dir);
> sort($files);
> reset($files);
> while (list($k, $v) = each($files)){
> echo $v, "<BR>\n";
> }
> ?>
> --
> Richard Lynch | If this was worth $$$ to you, buy a CD
> US Customer Support Director | from one of the artists listed here:
> Zend Technologies USA | http://www.L-I-E.com/artists.htm
> http://www.zend.com | (this has nothing to do with
> Zend, duh!)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>