Someone named "Jon" (no email) asked me for my random banner code. Since I know about 8 Jons, I’ll just post it here and hope he reads my blog regularly.
The image at the top of my blog changes each time you reload (or it’s supposed to. It’s random, so you COULD get the same one twice). The code that simply grabs all the filenames in a specified directory, strips off all the peripheral info, and picks on at random. Then you drop that into an img tag and you have a random image.
So here’s the code:
<?php
$banner = array();
if ($handle = opendir($_SERVER['DOCUMENT_ROOT'] . '/phlog/graphics/headers/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && (!strstr($file,'index')) && (!strstr($file,'htaccess')))
{
// echo "<a href="$file">$file</A><br>n";
$banner[] = $file;
}
}
closedir($handle);
}
//print_r($banner);
$rand_keys = array_rand($banner, 2);
print $banner[$rand_keys[0]];
?>
I didn’t even notice you had “random banners.”
Maybe you should overlay “Push F5 cuz I’m random” over the banner graphics.
-cvh (if you know multiple, i’m the cvh that has enriched your life the most)
You are certainly that.
Thanks, my bad 🙂