Correction to an error in the code...
Instead of:
$totalImages = array ("image1.gif","image2.gif","image3.gif");
$imagesCount = count ($totalImages );
srand ((double) microtime () * 1000000);
$number = rand(0,$imagesCount);
$randomImage = $totalImages [$number];
$smarty->assign("headimage",$randomImage);
It should be:
$totalImages = array ("image1.gif","image2.gif","image3.gif");
$imagesCount = count ($totalImages );
srand ((double) microtime () * 1000000);
$number = rand(0,$imagesCount - 1);
$randomImage = $totalImages [$number];
$smarty->assign("headimage",$randomImage);
Please note the following change:
$number = rand(0,$imagesCount);
To
$number = rand(0,$imagesCount - 1);
This will prevent going out of bounds on the array...so you don't get that icky "X" image not found graphic.
Thank you,
Tracy McClarnon
|