RE: dir to array?
| From: | Tim Ward | Date: | Thu, 01 Aug 2002 07:45:11 +0000 |
| Subject: | RE: dir to array? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-110636@lists.php.net to get a copy of this message | ||
> Not sure why this isn't working, any help is appreciated. I
> am trying to
> read the files in a directory and place them into an array.
> Here is the
> code:
>
> /* Function to create array of directory contents */
> function dCNTS($files) {
> $dir = opendir("/path/to/directory/");
> while($imgs = readdir($dir)) {
> if (($imgs != ".") && ($imgs != "..")) {
> $cnt[count($imgs)] = $cnt;
is this typo in the original code? surely should be " = $imgs;"
> } else {
> print "Cannot create array of files in directory!"; }
> }
> closedir($dir);
> }
Tim Ward
www.chessish.com