Hi I'm totally new at php and I put this script together modifying other scripts ... I'm trying to display multiple random non repeating images from a folder and it basically works except sometimes instead of an image I get a "blank" anyone can explain me why?
<?php
$imagesDir = 'images/';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$imageList = range(0,count($images));
shuffle($imageList);
$image_idx = 0;
echo'
<div class="main">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
</div>';
echo'
<div class="main">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
</div>';
echo'
<div class="main">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
</div>';
echo'
<div class="main">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
</div>';
echo'
<div class="main">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
</div>';
echo'
<div class="main">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
</div>';
echo'
<div class="main">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
<img src="' . $images[$imageList[$image_idx++]]. '" style="height:auto;width:33.33%;float: left">
</div>';
?>
Aucun commentaire:
Enregistrer un commentaire