Thanks for the suggestion.
I put the script outside the directory containing images. I changed "$handle = opendir( getcwd() )" to "$handle = opendir("images/")." It didn't give me any warnings, but it's not finding the images in the directory. It's returning an empty array (I think). Is there a problem elsewhere in the PHP, maybe?
<?php
$filetypes = array("jpg","jpeg","gif","png");
$filelist = array();
$handle = opendir("images/");
while ( false != ( $file = readdir($handle) ) ) {
if (is_file($file) && $file != "." && $file != "..") {
$extention = explode(".",$file);
$extfield = count($extention)-1;
$extention = $extention[$extfield];
if( in_array($extention,$filetypes) ) {
array_push ($filelist,$file);
}
}
}
$files = array_reverse ($filelist);
foreach ( $files as $file ) {
?>
<a name="<?= $file ?>" href="#<?= $file ?>"><img src="<?= $file ?>" alt="<?= $file ?>"></a>
<?php
}
?>