Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ramdom Images in PHP
#1
Thumbs Up 
A very wanted code is a ramdon in php of images something short and simple here I share it:

PHP Code:
<?php //create an array of images $images = array("sky.jpg", "swan.jpg", "tree.jpg", "waterfall.jpg", "apple.jpg"); //get the length of images array
//and a random number between 0 and the length $length = images.length(); $which = Math.round(Math.random()*(length-1)); //get the image at the index that matches the random number echo "<img src=\"$images[$which]\" />"; 
?>

Enjoy!
Reply
  


Forum Jump:


Users browsing this thread:
1 Guest(s)