Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

Random image example

This example uses an array to store images and then produces a random number and display the image on the screen . In real life you could display different banners , images etc

Here is the code for this example

<?php
//an array of 4 images in the same direcory as the script
$images = array("a1.gif","a2.gif","a3.gif","a4.gif");
//generate a random number
srand((double)microtime()*1000000);
$randomno = (rand()%4);
//display image
echo ("<img src=\"$images[$randomno]\">");
?>

And here is a working example