php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32569 array_rand problem with length of array
Submitted: 2005-04-04 16:06 UTC Modified: 2005-04-04 16:25 UTC
From: mail at sebastianburg dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.10 OS: Linux
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 + 22 = ?
Subscribe to this entry?

 
 [2005-04-04 16:06 UTC] mail at sebastianburg dot de
Description:
------------
array_rand($array,$num);

if $num > count($array) the return of array_rand is NULL



Reproduce code:
---------------
http://code.smb-media.de/?nr=5
http://code.smb-media.de/show/array_rand.php


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-04 16:25 UTC] betz@php.net
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

Try increasing your error_reporting level.
Make sure, to not pick more random values as your array holds elements.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC