ID: 28305 Updated by: [EMAIL PROTECTED] Reported By: anakin at php dot pl -Status: Open +Status: Bogus Bug Type: Math related Operating System: Windows XP PHP Version: 4.3.4 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php >From the manual: If you are picking only one entry, array_rand() returns the key for a random entry. Otherwise, it returns an array of keys for the random entries. This is done so that you can pick random keys as well as values out of the array. Your "actual results" are what you should expect, arrray KEYS 0 through 5. Previous Comments: ------------------------------------------------------------------------ [2004-05-06 19:44:31] anakin at php dot pl Description: ------------ Using array_rand wirh range function produces incorrect results. Reproduce code: --------------- <?php srand(); print_r(array_rand(range(1, 6), 6)); ?> Expected result: ---------------- An array with numbers from 1 to 6 shuffled. Actual result: -------------- For example: Array ( [0] => 4 [1] => 2 [2] => 3 [3] => 1 [4] => 0 [5] => 5 ) See key '4'. 0 (zero) does not match range(1, 6). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28305&edit=1
