I'm trying to use this code to list the files alphabetically but for some reason there are listed both, the files from the folder "items"and "images". I want only the files from the folder "images" to be listed.

PHP Code:
<?php
     
echo '<option value="null">Use url below</option>';
     
$dir opendir('../items/images/');
         while(
false !== ($file readdir($dir))) {
         if(
$file != "." && $file != ".." && $file != "Thumbs.db")
            {
            
$fileList[] = trim($file);
            }
}
sort ($fileList); // sort the file list in the array
reset ($fileList); // go back to the top of the array
while (list ($key$val) = each ($fileList)) {

                 echo 
'<option value="'.$val.'">'.$val.'</option>';
             
         }
         
closedir($dir);
     
?>
To list the files from the "items" folder i have this code :

PHP Code:
 <?php
     
echo '<option value="null">Use url below</option>';
         
$dir opendir('../items');
         while(
false !== ($file readdir($dir))) {
         if(
$file != "." && $file != ".." && $file != "Thumbs.db")
            {
            
$fileList[] = trim($file);
            }
}
sort ($fileList); // sort the file list in the array
reset ($fileList); // go back to the top of the array
while (list ($key$val) = each ($fileList)) {

                 echo 
'<option value="'.$val.'">'.$val.'</option>';
             
         }
         
closedir($dir);
     
?>
If i remove this last code the first will work correctly, any help how to make them both to work ?

EDIT, Changed the array for the second and it's fine now.