on Sun, 13 Jun 2004 01:15:20AM +0200, Kim Steinhaug insinuated: > Hmm... Ive been having same problems with mysql and picking random > numbers, I ended up having to program a rather more sofisticated > system to eliminate the stats you were referring to. > > You could, not that it will be any better, try another approach : > > Something like : > > $count = count($your_data_array); > $random = rand(0, $count); > echo $your_data_array[$random]; > > PHP is maby using the same random function for both the array_rand and > rand for all I know but its worth a go.
yeah, since they use the same thing i'm not sure it'd be worth the
effort.
> The harder way would be to include an internal counter for your
> elements you want to be randomized, so that when an item is selected
> you count it. Then the next time you calculate the random element
> you take the accual hits into meassure. There are like a 1000 ways
> to do this so use your imagination.
that would be cool. but how do you maintain the value of a counter
from reload to reload? would i have to open an external file, read
its variable, increment it, write to it, and close it every time? or
is there a way to do that in the code of a single php page?
thanks again,
</nori>
--
.~. nori @ sccs.swarthmore.edu
/V\ http://www.sccs.swarthmore.edu/~nori
// \\ @ maenad.net
/( )\ www.maenad.net/jnl
^`~'^
++ Sponsor me as I run my SECOND marathon for AIDS: ++
++ http://www.aidsmarathon.com/participant.asp?runner=DC-2844 ++
pgpPujqvc9NK6.pgp
Description: PGP signature

