john0611
08-11-2009, 02:06 PM
Hi all,
This one has got me thinking?
Is there a way to make this array random for images with .jpg extension, instead of file names as list here?
<?php // random image by file
$images = array(
array('file' => '2000-09painting4',
'caption' => ''),
array('file' => '2000-09painting7',
'caption' => ''),
);
$i = rand(0, count($images)-1);
$selectedImage = "img/random/paintings/{$images[$i]['file']}.jpg";
$caption = $images[$i]['caption'];
if (file_exists($selectedImage) && is_readable($selectedImage)) {
$imageSize = getimagesize($selectedImage);
}
?>
Thank you for your help and suggestions.
John.
This one has got me thinking?
Is there a way to make this array random for images with .jpg extension, instead of file names as list here?
<?php // random image by file
$images = array(
array('file' => '2000-09painting4',
'caption' => ''),
array('file' => '2000-09painting7',
'caption' => ''),
);
$i = rand(0, count($images)-1);
$selectedImage = "img/random/paintings/{$images[$i]['file']}.jpg";
$caption = $images[$i]['caption'];
if (file_exists($selectedImage) && is_readable($selectedImage)) {
$imageSize = getimagesize($selectedImage);
}
?>
Thank you for your help and suggestions.
John.