I'm looking to write a PHP script that will post images from a directory into a table format that is 8 columns wide and the rows extend as many images as there are. This current code I have only posts them in separate rows. How can I divide them into rows of 8 images?
<?php
$files = glob("images/*.*");
for ($i=1; $i<count($files); $i++)
{
$image = $files[$i];
$supported_file = array(
'gif',
'jpg',
'jpeg',
'png'
);
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
// print $image ."<br />";
echo '<a href="' .$image .'"><img src="'.$image .'" alt="Random image" width=200 /></a>'."<br /><br />";
} else {
continue;
}
}
?>