note 56730 deleted from function.rand by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.