RANDOM IMAGES

 

If you want to know how to generate a random images on your site keep reading!

This script is used to generate a random image every time the page is refreshed.

Now that you know what it does follow these easy steps to create your own!

 

1. Make a new .php file and name it randomimage.php.

2. After that you will need to copy and paste this code into the page you just made.

All the images you are going to use must be in the same directory as randomimage.php.

If you are using something other than gif then make sure you change the file extension.

 

<?php
header("Content-Type: image/gif");
$sigs = array();
$sigs[] = "imagename1.gif";
$sigs[] = "imagename2.gif";
$sigs[] = "imagename3.gif";

mt_srand((double)microtime()*1000000);
$sig = $sigs[mt_rand(0, count($sigs)-1)];

readfile($sig);

?>

 

Now you need to use the code below to put it where you want the random image to show up.

 

<?php include("randomimage.php"); ?>

 

Don't forget that any page you add the php include to must have a .php extension.  If not it wont work! :)

Hosted by www.Geocities.ws

1