in reply to remove a random variable from an array
you need the int() since rand returns a decimal, and you were trying to splice out the value of the array index, not the actual index number...for($i=1; $i<=$a; $i++){ $randomelement = int(rand @thumbs); print "<img src=\"$picture_directory/$thumbs[$randomelement]\"> +$picture_directory/$thumbs[$randomelement]<br>"; splice(@thumbs, $randomelement,1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(bbfu) (integer array indices) Re(2): remove a random variable from an array
by bbfu (Curate) on Apr 20, 2001 at 02:02 UTC | |
by suaveant (Parson) on Apr 20, 2001 at 17:32 UTC |