samedi 28 mars 2020

Exclude random number in PHP WHILE KEEPING chr(49+rand(0,1))

I have a random number. 1 or 2 for sake of testing.

$rn = chr(49+rand(0,1)) ;

I want to then exclude that $rn from another $rn2. So if the first $rn is 2, I want the second $rn2 to be 1.

Currently this KIND OF works...

while( in_array( ($rn2 = rand(1,2)), array($rn) ) );

...although this is NOT correct as I NEED the

chr(49+rand(0,1))

to remain in the code, where the rand(1,2) currently is.




Aucun commentaire:

Enregistrer un commentaire