jeudi 23 février 2017

Fetch images randomly from directory?

I am no too proficient in PHP yet and I have this code which works so far.

<?php 
$id = JRequest::getInt('id');
$dirname = "media/k2/galleries/{$id}/";
$images = glob($dirname."*.jpg");
$rand = array_rand($dirname);
?>
<?php foreach($images as $image): ?>

<li><span class="shadowborder"><img src="<?php echo $image ?>" /></span>    </li>
 <?php endforeach; ?>

I have tried to add an array, I know $images and $image should be swapped out but as you can see but I cannot get it to gel, what am I missing? Thanks!




Aucun commentaire:

Enregistrer un commentaire