Hello. I recently started learning PHP. One of my first tasks has been to write a simple script that obtains the filenames of several files in a subdirectory and then prints them. (I am building up to a script that shall output the HTML necessary to display a page of thumbnails which link to full-sized photos.) My script's source is as follows:
The output from this script is composed only of the <BR> and \n statements; it simply does not output any file names. I shall appreciate any assistance that you can provide. Thanks in advance.PHP Code:$imageDir = ImageList ("screens/small");
for ($i = 0; $i < count ($imageDir); $i++) {
printf ("%s<BR>\n", $imageDir[i]);
}
function ImageList ($sPath) {
//Load Directory Into Array
$imageList = array();
$handle = opendir ($sPath);
while ($file = readdir($handle)) {
if ($file != "." && $file != "..") {
array_push ($imageList, "$file");
}
}
//Clean up and sort
closedir ($handle);
sort ($imageList);
return $imageList;
}




Bookmarks