I'm trying to count the images in my folder and want to clear the float after each 6 images returned from a folder. Here's the code I've got so far but it spits out the clear more than the amount I'd like for it. Could somebody maybe guide me to a solution? Thanks in advance. Below is my code.
<?php
$i = 0;
$dirname = "images";
$images = scandir($dirname);
$filecount = count(glob("images/". "*.png"));
//echo $filecount;
$ignore = Array(".", "..", "otherfiletoignore");
foreach($images as $curimg){
if(!in_array($curimg, $ignore)) {
if ($i % 6 === 0){
echo "<div style='clear:both;></div>'";
}
echo "<div style='float:left;'><img src='images/",$curimg."'"," /></div>";
}
}
?>