View Full Version : Random Avatar

10-08-2004, 10:53 PM
I tried to make a random avatar that will change everytime people refresh their browsers, but I couldn't make it. Here was what I did [help me !!]


// Setup the information about our random images
$imgs = array(

// Image Name/Path MIME Type (Look below for common Image MIME types)
array("your pic", "image/jpeg",),
array("your pic", "image/jpeg",),
array("your pic", "image/jpeg",),


| Common Image MIME types
| GIF: "image/gif"
| JPG: "image/jpeg", "image/pjpeg"
| PNG: "image/png", "image/x-png"

// There is no need to edit anything below this line.

// Seed the random number generator
$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];

// Find the total images
$imgs_total = count($imgs);

// Choose a random number from 0 to end of array
$random = rand(0, ($imgs_total - 1));

// Make sure the user is going to actually keep retreiving the image (an image in cache is not random)
@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
@header("Cache-Control: no-cache, must-revalidate");
@header("Pragma: no-cache");

// Required, tells the browser what time of file we're sending it's way.
@header("Content-Type: ".$imgs[$random][1]);

// open the picture file

// End Random Image script
Go to NotePad and Paste this Code
After that save it as name.gif

* REPLACE THE your pic with your image.

Then, Open the NEW Note Pad

Paste this this Code:

<Files name.gif>
ForceType application/x-httpd-php

And save that as ANYNAMETHATYOUWANT.htaccess
Then Upload all of them , and your pictures (all of the picture that you put on the "your pic" ) to one Folder