Hi all i got this code i need help with ist mind killing, a random image rotator
i did everything it said to do where to put the path to my images but nothing came out please see what i did wrong. please help
Thank You.
this is what i had for my path: caribbeanbizconnections.com/randimages
this is what i had for image url: http://www.caribbeanbizconnections.com/randimages
<?php
$imageDirectory = '/path/to/images/';
$imageURL = '/url/to/images/';
$randomImage = $imageURL . randomImage($imageDirectory);
function randomImage($dir) {
$files = array();
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (false !== ($file = readdir($dh))) {
if ($file != "." && $file != "..") {
$files[] = $file;
}
}
closedir($dh);
}
}
$totalImages = count($files);
$maxImages = $totalImages - 1;
$randomImage = rand(0, $maxImages);
return $files[$randomImage];
}
?>
<img src="<?= $randomImage ?>" />
i did everything it said to do where to put the path to my images but nothing came out please see what i did wrong. please help
Thank You.
this is what i had for my path: caribbeanbizconnections.com/randimages
this is what i had for image url: http://www.caribbeanbizconnections.com/randimages
<?php
$imageDirectory = '/path/to/images/';
$imageURL = '/url/to/images/';
$randomImage = $imageURL . randomImage($imageDirectory);
function randomImage($dir) {
$files = array();
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (false !== ($file = readdir($dh))) {
if ($file != "." && $file != "..") {
$files[] = $file;
}
}
closedir($dh);
}
}
$totalImages = count($files);
$maxImages = $totalImages - 1;
$randomImage = rand(0, $maxImages);
return $files[$randomImage];
}
?>
<img src="<?= $randomImage ?>" />
Comment