Hello all,
I am learning, please be gentle as I try to get better.
I have a page with two different images that are pulled at random for display on the page in different locations. That works fine. However, I want the images to be a matching pair, like a headline and matching banner.
I don't know how to do that or where to find a tutorial on what the technique would be.
In pseudo-code:
Execute random image script
and grab banner image from folder "banner."
Grab matching image N from folder "headline."
Essentially, two matching images both named N.gif but pulled from different folders could be displayed. They could be in the same folder, I just want both images N1.gif and N2.gif to display at once.
my php random pull starts like this
<?php
$folder = "banner";
$fileList = array();
$handle = opendir($folder);
while (false !== ($file = readdir($handle) ) ) {
if ( substr($file, -4) == ".gif" || substr($file, -4) == ".jpg" ) {
$fileList[count($fileList)] = $file;
}
}
closedir($handle);
$randNum = rand( 0, (sizeOf($fileList) -1) );
if ( substr($fileList[$randNum], -4) == ".gif" ) {
header ("Content-type: image/gif");
} elseif ( substr($fileList[$randNum], -4) == ".jpg" ) {
header ("Content-type: image/jpeg");
}
readfile($fileList[$randNum]);
?>
I am learning, albeit slowly.