config['(site_url)'].'assets/images/'.$Location.'/'; // set path to files $dir_array = array(); // main array - contains all file names in directory // open directory and parse file list if (is_dir($dir)) { if ($dh = opendir($dir)) { // iterate over file list to create full directory array while (($filename = readdir($dh)) !== false) { if (($filename != ".") && ($filename != "..") && ($filename !="WS_FTP.LOG") && (!preg_match('/^.thumb_/', $filename))) { // skip self, parent, and ftp log and thumb prefix $dir_array[] = $filename; // add the filename to the array } } closedir($dh); // close directory } natsort($dir_array); // sort in ascending order -- delete if you don't need them sorted. // $dir_array = array_reverse($dir_array, false); // reverse array (descending) if needed. $n = count($dir_array); // total number of files -- might want this for something $output = ''; $output .= '