coder9 Posted July 24, 2008 Share Posted July 24, 2008 Hi i have 5 random numbers every time i refresh the page it generate 5 random numbers. how do i check them that there are no duplicate numbers between the five numbers. let say 1, 4, 3, 4, 7 as you can see the 2nd and 4th are the same. can you show me some code that will detect them in vice versa. or is there a built in function in php that will do this. Thank you. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted July 24, 2008 Share Posted July 24, 2008 make sure it doesn't generate duplicate numbers in the first place is easier... google these things <?php $numbers = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25, 26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49); $pkt = array(); shuffle($numbers); for ($i=1;$i<7;$i++){ $pkt[] = $numbers[$i]; } sort($pkt); echo "Randomly Generated Lotto Numbers <br />"; for ($d=0;$d<6;$d++){ echo "$pkt[$d] "; } ?> http://www.spikemeister.co.uk/?p=94 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.