note 13719 deleted from function.array-unique by progcom
| From: | progcom@php.net | Date: | Fri, 09 Apr 2004 01:24:05 +0000 |
| Subject: | note 13719 deleted from function.array-unique by progcom | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67854@lists.php.net to get a copy of this message | ||
Note Submitter: info@phpcoding.net
----
Following function returns an array containing unique random numbers. In my opinion a nice way of
using array_unique:
function rand_numbers($min,$max,$item_nbr)
{
$return_array = array();
while (count($return_array)<$item_nbr)
{
$return_array[] = rand($min,$max);
$return_array = array_unique($return_array);
}
return $return_array;
}
$min and $max set the range for the rand() function. Use $item_nbr to tell the function how many
random, unique numbers you want.
(Feedback is appreciated)