Populating array with function

From: Date: Tue, 27 Feb 2007 11:34:24 +0000
Subject: Populating array with function
Groups: php.general 
Request: Send a blank email to php-general+get-249484@lists.php.net to get a copy of this message
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

« previous php.general (#249484) next »