mariomtti;11054689 wrote:Hi All,
Looking to create a rand num generator between 0-21 - without duplicates...
I can create the generator part but the random part if where I'm falling...
<?php
$min=0;
$max=21;
echo rand($min,$max);
?>
Any ideas?
Thanks,
Mario
That IS a random number generator ... although [man]random_int/man is the "cryptographically secure" version.
Of course, what you mean is, "I want to create a generator for an array of random numbers..."
Because one number cannot have a duplicate if it's just one number.
Of course, laserlight's back from Japan and has it cold on the first post. 😉
There's also an [man]array_rand/man that gives a pseudo-random array, if that is more what you're looking to do.
Welcome to PHPBuilder Mario, and please consider using [noparse]
[/noparse] tags around your PHP code in your next post! 🙂
sneakyimp wrote:I had no idea shuffle existed! I've reinvented this wheel soooo many times.
It's a Revelation Moment, ain't it? IIRC, Weedpacket introduced me to that one [thread=10215875]umpteen years ago right here on PHPBuilder[/thread]....