Hi I am building a website and I want to display a random image every time the page is refreshed. Since I know php, I figured it would be easiest to do it using that language. Does anyone know how to do this? Thanks - Derek
<?php $images = array( 'image1.jpg', 'image2.jpg', '...' ); header('Content-Type: image/jpeg'); readfile($images[array_rand($images)]); ?> PHP:
lets you have images at same folder where php file img1 img2 img3 . . . img50 <img src="img<? echo rand(1,50); ?>" > PHP:
Copy the code that nico has given you into a file called image.php and call it from you html document using <img src="image.php" /> Brew
It works. $images = array( 'http://www.website.com/image1.jpg', 'http://www.website.com/image2.jpg', '...' ); echo'<img src="'.$images[array_rand($images)]).'">'; Code (markup):