Hi all,
I am trying to generate a random image form file within a list item.
I am missing something but trying to figure it out, here is my code I am working with:
Thank you for any help and suggestions.PHP Code:<!-- bg img -->
<?php
$images = array(
array('file1' => 'bg',
'caption' => ''),
array('file2' => 'bg2',
'caption' => ''),
);
$i = rand(0, count($images)-1);
$selectedImage = "img/{$images[$i]['file1'] ['file2']}.jpg";
$caption = $images[$i]['caption'];
if (file_exists($selectedImage) && is_readable($selectedImage)) {
$imageSize = getimagesize($selectedImage);
}
?>
<div class="jbgallery">
<ul>
<li><a href="<?php echo $selectedImage; ?>">1</a></li>
<li><a href="<?php echo $selectedImage; ?>">2</a></li>
</ul>
</div>
<!-- end -->



Reply With Quote

Bookmarks