Log in

View Full Version : Random Picture Generator



thehealey
06-07-2007, 05:17 PM
Ahoy,
I was trying to think up new ideas for a sig on a forum when I came up with the idea of having separate images that would randomly change when the page gets refreshed. Of course being a typical forum, HTML is not aloud in sigs & the only way to get an image in a sig is using BBcode.

So I figure the only way to have a different pic, from a pre-selected list of 4, is to make the image file randomly change on load/refresh. Is that possible? How would I go about making that happen?

Everyone else I've asked says it's impossible, so I wouldn't be to broken hearted if you say the same.

boxxertrumps
06-09-2007, 03:32 AM
hmmmm...


<?php $pics = array(
array("URL to pic","Mime type"),
array("otherpic.jpg","image/jpeg"),
array("directory/differentpic.png","image/png"),
array("http://domain.com/pic.bmp","image/bmp")
);
$key = array_rand($pics);
header('Content-type: '$pics[$key][1]);
echo file_get_contents($pics[$key][0]); ?>

put this into a php file on a web server, and replace the URLs with actual URLs(reletive to the php file) and the mime types with the coresponding mime types.
you can have as many of the inner array()s as you want, as long as you have one comma in between each.

EDIT: you have to link to that php file in your sig.