note 56730 deleted from function.rand by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:44:08 +0000 |
| Subject: | note 56730 deleted from function.rand by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134429@lists.php.net to get a copy of this message | ||
Note Submitter: Viking Coder
----
To mark at mmpro dot de, or anybody else wanting a unique list of random numbers in a given range.
$min=1;
$max=10;
$count=5;
$list=range($min,$max);
shuffle($list);
$list=array_slice($list,0,$count);
andy at andycc dot net, this can also be used to generate random strings.
$length=8;
$list=array_merge(range('a','z'),range(0,9));
shuffle($list);
$string=substr(join($list),0,$length);