From:             alisovoi at hotmail dot com
Operating system: Linux Redhat 9
PHP version:      4.3.4
PHP Bug Type:     Reproducible crash
Bug description:  array_rand() not random

Description:
------------
$array[array_rand($array)] is always the same element of the array. 
The server uses php.ini-recommended for the configuration.
(In PHP 4.3.2, this problem is non-existant. PHP 4.3.4 has this bug)

Reproduce code:
---------------
<?php
$random_sayings = array('Hey, this is not','randomly chosen','elements
from an array');
echo($random_sayings[array_rand($random_sayings)]);
?>

Expected result:
----------------
Either one of the 3 elements of the array.

Actual result:
--------------
The same element no matter how many times the user refreshes.

-- 
Edit bug report at http://bugs.php.net/?id=26290&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26290&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26290&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26290&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26290&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26290&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26290&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26290&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26290&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26290&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26290&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26290&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26290&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26290&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26290&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26290&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26290&r=float

Reply via email to