Endless Paradigm

Full Version: Avatar change on refresh? [For Sale - .0030 EP]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
How do you do it?!
a php script used instead of image
The php script chooses from an array of images.
Thanks for the fast reply.
I haz the code

PHP Code:
#
$input = array("image1.jpg",
#
               "image2.jpg",
#
               "image3.jpg",
#
               "image4.jpg",
#
               "image5.jpg");
#
$site = "http://somesite.com/images/";
#
$random = array_rand($input, 1);
#
echo '<img src="'.$site.$random.'">';; 


What to do with it?

This is the one ive used.

Code:
<?php
/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';

$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) { // for each extension check the extension
if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
$files[] = $file; // it’s good
++$i;
}
}
}
closedir($handle); // We’re not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along

header('Location: '.$folder.$files[$rand]); // Voila!
?>


You need to host this on a server, any free one will do.

Ah wait, I got it.  I'll try this out right now and reply when I'm done.
Bah, I uploaded the php file and the images to my server.  Now what?
Jaze Wrote:Bah, I uploaded the php file and the images to my server.  Now what?

edit the php file, read the comments "//" to know what to change.
basically upload the image and php files to the same location, then call the php file through the address bar, should display an image.
I changed everything.
What's the server's address?
http://programmersparadise.co.cc/

The images are in
/images/dis3_mao.png
/images/intro.png

and the php file is in
/images/image_swap.php
Pages: 1 2 3
Reference URL's