11-27-2007, 03:12 AM
|
#2 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Good tip! There is also the array_rand way. However, as I was trying it just now, it seems to love its zeros, so I decided to do a little test as well. This is the array_rand code:
php Code:
$aFilms = array("V For Vendetta", "Requiem For A Dream", "Jacob's Ladder"); echo $aFilms[array_rand ($aFilms)];
And this is my test code as it appeared to be quite fond of returning zero:
php Code:
$aCount = array(0, 0, 0); $aFilms = array("V For Vendetta", "Requiem For A Dream", "Jacob's Ladder"); for($iIndex = 0; $iIndex <= 5000; $iIndex++ ){ $aCount[array_rand ($aFilms)]++; }print_r($aCount);
Results were quite surprising as I thought zero would have been much more dominant:
Quote:
Array
(
[0] => 1701
[1] => 1637
[2] => 1663
)
|
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|