array_rand() not random

From: Date: Fri, 11 Jun 2004 17:45:31 +0000
Subject: array_rand() not random
Groups: php.general 
Request: Send a blank email to php-general+get-188122@lists.php.net to get a copy of this message
hi, i'm trying to use the array_rand() to return one of six images, culled from a directory listing. however, i've noticed that over the past five days, the log of images accessed is anything but a random distribution: 20 /jnl/images/banner/banner_viola.jpg 32 /jnl/images/banner/bw_banner.jpg 35 /jnl/images/banner/alyssa_banner.jpg 104 /jnl/images/banner/coffee_banner.jpg 147 /jnl/images/banner/banner_bracelets.jpg 193 /jnl/images/banner/orange_wig_banner.jpg i'd like to see the others pop up a bit more -- like, ever. i'm seeding the random method with srand, even though i'm running php 4.3.3 and shouldn't need to. i tried the shuffle() method like was suggested on the manual page for the array_rand() method, but can't make it work -- it returns an array of the indices(!). (am i doing this right? it would just be shuffle($banners); , right?) is there a common workaroud for this problem? what do other people do for more randomized random array selections? thanks, </nori> -- .~. nori @ sccs.swarthmore.edu /V\ http://www.sccs.swarthmore.edu/~nori // \\ @ maenad.net /( )\ www.maenad.net/jnl ^`~'^

« previous php.general (#188122) next »