Need help with this. I'm trying to write an if/then statement that will enable me to display a random image based on the time that the user is viewing the site.
I keep getting an error in the line that is defining $myimages.
Any thoughts why I would keep getting a parse error would be GREATLY APPRECIATED!
<?php
// print a random image. Don't forget ending slash!
// setting $type to 'all' will return all images.
$date_time = date('g');
IF ($date_time > "6"); {
THEN $myimages == getRandomImage('nightimages/');
} ELSE {
$myimages == getRandomImage('dayimages/');
}
function getRandomImage($dir,$type='random')
{
global $errors,$seed;
if (is_dir($dir)) {
$fd = opendir($dir);
$images = array();
while (($part = @readdir($fd)) == true) {
if ( eregi("(gif|jpg|png|jpeg)$",$part) ) {
$images[] = $part;
}
}
// adding this in case you want to return the image array
if ($type == 'all') return $images;
if ($seed !== true) {
mt_srand ((double) microtime() * 1000000);
$seed = true;
}
$key = mt_rand (0,sizeof($images)-1);
return $dir . $images[$key];
} else {
$errors[] = $dir.' is not a directory';
return false;
}
}
?>