Good day to you all,
The below code search for image in a directory and show them in row of 5.

PHP Code:

 <?php
$image_counter 
3;
$row_counter 0;
$cell_counter 0;
$show=array('.jpg','.JPG','.gif','.GIF');
$path './images/';
$dir_handle = @opendir($path) or die("Unable to open $path");
$image_table "<table>\n<tr><th colspan=5>Existing Pics in Directory:</th></tr>\n<tr>";
while (
false !== ($file readdir($dir_handle))) {
  if(
in_array(substr($file,-4,4),$show)){
        if(!((
$image_counter 2) % 5)){
          
$row_counter++;
        }
      
$image_table .=(($image_counter 2) % 5)? "" "</tr>\n<tr>";
      
$image_table .= "\n<td><img src=\"$path$file\"><br>$file</td>\n";
      ++
$image_counter;
      ++
$cell_counter;
  }

}
$colspan= ($row_counter 5) - $cell_counter;
$image_table .= ($cell_counter 5) ?  "<td colspan=$colspan>&nbsp;</td>" "";
$image_table .= "</tr>\n</table>\n";
echo 
"$image_table<br><br>";
echo 
"<b>Total Cells w pics: $cell_counter<br>";
echo 
"<b>Total Rows: $row_counter<br>";
echo 
"<b>Empty Cells in last row: $colspan";
?>
My question is if the code find lets say 100 image, how can I split the result in page of 5 row ?

Thanks !