rofl90 Posted July 31, 2008 Share Posted July 31, 2008 What I want to do is: $flagIdRand_Correct = rand(0, 999); //update to amount of flags correct answer $flagIdRandWrong_a = rand(0, 999); //incorrect answer 1 $flagIdRandWrong_b = rand(0, 999); //incorrect answer 2 $flagIdRandWrong_c = rand(0, 999); //incorrect answer 3 4 random numbers, they all need to be different..hwo would i do this Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 31, 2008 Share Posted July 31, 2008 I'd do it like this: <?php $array = range(0,999); shuffle($array); $rand = array_slice($array,0,4); print_r($rand); ?> Quote Link to comment Share on other sites More sharing options...
rofl90 Posted July 31, 2008 Author Share Posted July 31, 2008 Could you run me through what that does, and what it'll return, I presume a $rand[0, 1,2,3]? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 31, 2008 Share Posted July 31, 2008 <?php $rands = range(0,999); //Makes an array from 0 to 999 shuffle($rands); //Randomizes the array $flagIdRand_Correct = rands[0]; //update to amount of flags correct answer $flagIdRandWrong_a = rands[1]; //incorrect answer 1 $flagIdRandWrong_b = rands[2]; //incorrect answer 2 $flagIdRandWrong_c = rands[3]; //incorrect answer 3 ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.