Page 1 of 1

Lotto programming

Posted: Thu Apr 21, 2011 12:17 pm
by Dilbert137
Dear All,

I would like to start a little project for my own leisure time on the lottery gaming programming. Can someone know where to find some programming examples for lotto concerning 6 numbers from 1 to 40 and how it works in reality. Is there some documentations on lotto programming?

Thanks and Best Regards
Dilbert137

Re: Lotto programming

Posted: Thu Apr 21, 2011 12:18 pm
by fugix
id imagine they have numbers stored in a db and they draw them out randomly

Re: Lotto programming

Posted: Fri Apr 22, 2011 3:07 am
by shauns2007
I don't think anybody would know exactly how the lottery draws the numbers besides the big guys at the lottery them selves :) What exactly do you want to do? I created a little lotto app the other day by adding all the numbers to an array then using array_rand to extract 6 random numbers. Is this something you looking for?

Re: Lotto programming

Posted: Fri Apr 22, 2011 6:34 am
by fugix
Sounds like that would work too shauns

Re: Lotto programming

Posted: Fri Apr 22, 2011 7:39 am
by shauns2007
Here is the code

Code: Select all

$lotto_numbers = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 
						   10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 16 => 16, 
						   17 => 17, 18 => 18, 19 => 19, 20 => 20, 21 => 21, 22 => 22, 23 => 23,
						   24 => 24, 25 => 25, 26 => 26, 27 => 27, 28 => 28, 29 => 29, 30 => 30,
						   31 => 31, 32 => 32, 33 => 33, 34 => 34, 35 => 35, 36 => 36, 37 => 37,
						   38 => 38, 39 => 39, 40 => 40, 41 => 41, 42 => 42, 43 => 43, 44 => 44,
						   45 => 45, 46 => 46, 47 => 47, 48 => 48, 49 => 49);
	$random1 = array_rand($lotto_numbers,6);
	sort($random1);	
	$string = "Your lucky quick pick numbers are as follows: ";
	print $string;
	print $random1[0]. ", ";
	print $random1[1]. ", ";
	print $random1[2]. ", ";
	print $random1[3]. ", ";
	print $random1[4]. " and ";
	print $random1[5];