note 38438 rejected from function.array-rand by vincent
| From: | vincent@php.net | Date: | Sun, 21 Dec 2003 09:30:50 +0000 |
| Subject: | note 38438 rejected from function.array-rand by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62290@lists.php.net to get a copy of this message | ||
Note Submitter: grio@grio.net
----
array_rand() seems to be broken, at least in 4.3.1.
I fought it for several hours, until just doing this instead:
$selected = $ida[rand(0,count($ida)-1)];
$selected is the singular answer I was looking for, and $ida is the array I was working with. If
you're looking for a singular answer, this is the easiest way. Replace $ida with your array of
values you're looking for, and $selected will be your singular answer. Hope this helps for
someone. Don't spend hours on array_rand() like I did.