|
Posted by jukka on 01/01/06 15:37
> [code]
> <?php
> $picture_array = array("car.jpg","cat.gif","cow.png");
> $rand_no = rand(0,3);
> echo "<img src=\"".$picture_array[$rand_no]."\" />";
> ?>
> [/code]
> <?php
> $picture_array = glob("*.*");
> $rand_no = rand(0,"count($picture_array)");
> echo "<img src=\"".$picture_array[$rand_no]."\" />";
> ?>
Correct me if I'm wrong, but shouldn't it be $rand_no - 1? Since three
pictures would be 0,1,2 and if the random number is between 0-3 it could
be 3, which is not in our array.
[Back to original message]
|