hankknight
asked on
8 Unique Numbers
Hello,
I need to randomly generate 8 UNIQUE random numbers.
No number may be used more than once.
So this number is good:
53962471
This number is NOT because some numbers are duplicated:
11223344
What is the shortest/simplest way to do this?
I need to randomly generate 8 UNIQUE random numbers.
No number may be used more than once.
So this number is good:
53962471
This number is NOT because some numbers are duplicated:
11223344
What is the shortest/simplest way to do this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I feel silly answering my own question but the ideas keep getting more complex.
One of your ideas triggered a lightening bolt in my head and I came up with this.
What do you think?
One of your ideas triggered a lightening bolt in my head and I came up with this.
What do you think?
<?php
$str = '0123456789';
$shuffled = str_shuffle($str);
echo substr($shuffled,-8);
?>
Yes, that will work, and will allow you to start with as large a data set as desired.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window