Please don't use tractors version, but us this one insted:
code:
<?php
$dir = "imgs";
$dh = opendir($dir);
$files = array();
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
array_splice($files, 0, 2);
srand( (double) microtime()*1000000 );
$key = array_rand($files);
header("location: $dir/".$files[$key]);
?>
The difference?
This version allows give the browsers a chance to cache the images