PROTECTED]
Subject: [PHP] Randomizing 3 different numbers.
I am tring to output 3 different random numbers between 1
and 20 into 3 different strings. Using Rand() for each
string isn't sufficient as I may get the same number
repeated for one of the other strings- eg 1,1,3 or 5,3,3 .
It's
Dont you mean || at the last loop? You loop as long as 3 is equal to both 1
and 2, || would cause it to loop while it's equal to any of them..
--
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
##
Please, if you are using windows, you may be infected by Swen
03 15:56
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Randomizing 3 different numbers.
Before you add a number to a string make sure that the number is not in
any of the other ones if they exist.
Use a do-while loop on it...
$one = rand( 1,20 );
do {
$two = rand( 1, 20 );
}while( $two == $on
Before you add a number to a string make sure that the number is not in
any of the other ones if they exist.
Use a do-while loop on it...
$one = rand( 1,20 );
do {
$two = rand( 1, 20 );
}while( $two == $one );
do {
$three = rand( 1, 20 );
}while( ($three == $one) && ($three == $two) );
echo
I am tring to output 3 different random numbers between 1
and 20 into 3 different strings. Using Rand() for each
string isn't sufficient as I may get the same number
repeated for one of the other strings- eg 1,1,3 or 5,3,3 .
It's important that I get three different numbers outputted
into for exam
5 matches
Mail list logo