Populating array with function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I need to populate an array with the contents of a directory. The
following code does not populate the $thumbnailFiles array like I
expect that it would:


<?php

function listFiles ($directory) {
   $files=array();
   $dir = dir($directory);
   while ($entry = $dir->read()) {
       if (  !is_dir($entry)  ) {
           $files[] = $entry;
           print $entry."<br />";  // DEBUG CODE - REMOVE ME
       }
   }
   $dir->close();
   return $files;
}

$thumbnailsDirectory="/home/user/public_html/photostorage/160x120";
$lqDirectory="/home/user/public_html/photostorage/240x320";
$mqDirectory="/home/user/public_html/photostorage/800x600";
$hqDirectory="/home/user/public_html/photostorage/1600x1200";

$thumbnailFiles=array();
$lqFiles=array();
$mqFiles=array();
$hqFiles=array();

$thumbnailFiles=listFiles($thumbnailsDirectory);

print"<pre>";
print_r($thumbnailsFiles);
print"</pre>";


?>

The print statement does in fact print the files, so I know that I've
gotten _that_ far. How should I return the contents of $files to
$thumbnailFiles?

Dotan Cohen

http://lyricslist.com/lyrics/artist_albums/612/zion_i.html
http://what-is-what.com/what_is/php.html

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux