PHP/Data Structure/array rand
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>
array_rand
<?php
$states = array("Ohio" => "Columbus", "Iowa" => "Des Moines","Arizona" => "Phoenix");
$randomStates = array_rand($states, 2);
print_r($randomStates);
?>
mixed array_rand ( array arr [, int amount] )
<?
$natural_born_killers = array("lions", "tigers", "bears", "kittens");
$two_killers = array_rand($natural_born_killers, 2);
?>