$i =1; while ($file = readdir($opendir)) { //exclude anything that doen't look like files. if($file != '..' && $file !='.' && $file !=''){ //dont't read direcories insde our directory. if (!is_dir($file)){ $filename1 = "./images/big/$file"; if (file_exists($filename1)) { // since i am using gallery we have to get the width and hieght of photos. $imgsize = getimagesize ($path_big."/".$file); // lets get the file size in byte/kb/mb. $file_size = filesize($path_big."/".$file); if ($file_size >= 1048576){ $show_filesize = number_format(($file_size / 1048576),2) . " MB"; }elseif ($file_size >= 1024){ $show_filesize = number_format(($file_size / 1024),2) . " KB"; }elseif ($file_size >= 0){ $show_filesize = $file_size . " bytes"; }else{ $show_filesize = "0 bytes"; } $filearray[] = $file; }else{ echo "Cannot find: $file "; } } } }//end while loop //define a variable to hold everthing that will be printed in table's columns. $all_stuff = "File name: $file
REMOVE THIS IMAGE

Size: $show_filesize
Width : $imgsize[0] px
Height : $imgsize[1] px"; //divide the loop ($i) and ($cols) if the result is integer //then print column number 1. if (is_int($i / $cols)){ echo "$all_stuff"; }else{ //else then print column number 2 etc for the next loop. echo "$all_stuff"; } //add only 1 for the loop ($i). $i++; closedir($opendir); clearstatcache(); // print the rest of table. echo " "; //print copyright ;) echo"


";