A Random-Image Script Using array_rand() : array_rand « Data Structure « PHP






A Random-Image Script Using array_rand()

 
<HTML>
<HEAD><TITLE>A random image script</TITLE></HEAD>
<BODY>
<?php
    srand((double)microtime()*1000000);
    $images = array('image1.jpg', 'image2.jpg', 'image3.jpg');
    $rImage = array_rand($images)
?>
<IMG SRC="<?php echo $images[$rImage]; ?>">
</BODY>
</HTML>
  
  








Related examples in the same category

1.array_rand
2.mixed array_rand ( array arr [, int amount] )