Jump to content

somone tell me whats going on herE? LOL


Monkuar

Recommended Posts

$correct_numbers = 0;
				$correct = 0;
				$numbers_chosen = @explode("|",$ticket['numbers_chosed']);
				$your_numbers = array();
				$array1 = array_count_values($numbers_chosen);
				$array2 = array_count_values($winning_numbers);
				foreach($array1 as $number1 => $count1)
				{
				foreach($array2 as $number2 => $count2)
				{
				if($number2 == $number1 and $count2==$count1)
				$correct_numbers += $count2;
				}
				}
				$use = 0;
				$numbers = @implode("|",$winning_numbers);
				echo $correct_numbers;
				echo "<br>";
				echo $lottery['balls'];

 

I have no idea wthell this does

$correct_numbers += $count2;

 

What's that += suppose to mean?

 

I know the $correct_numbers is supposed to be a matching array count from the for eachs right?

 

 

$ticket['numbers_chosed']

 

is

 

8|18|3

Link to comment
https://forums.phpfreaks.com/topic/255748-somone-tell-me-whats-going-on-here-lol/
Share on other sites

With what? Do you not understand what:

 

$correct_numbers = $correct_numbers + $count2;

 

does?

 

Yeah I understand what it does now, I just didn't know what the += i never seen that operator before,

 

 

Problem I am having is

 

echo $correct_numbers;

 

is echoing out

 

0 or 1 every other refresh

 

And it's supposed to match

 

if($correct_numbers == $lottery['balls'])

 

$lottery['balls'] is my MAX number of Balls to match, which is set to 3.

 

$winning_numbers are

 

8|18|3

 

And the $ticket['numbers_chosed'] are

 

8|18|3

 

It should be echoing out 3 instead of 0 or 1 right? ?because it's Matching each array with each individual ball?

 

Here is the full function (not that long dont worry)

 

if($end_date < time() and $lottery['type'] == 'exact') {

		//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

			$this->drawn_lotto++;
			$winning_numbers = $this->choose_numbers($lottery['balls'],$lottery['max_number'], $lottery['type']);
			$wn = implode("|",$winning_numbers);
			$winning_numbers = explode("|", $wn);

			$query = $DB->query("SELECT l.*,m.name,m.id FROM ibf_lottery_tickets l
							LEFT JOIN ibf_members m ON (m.id=l.memberid)
							WHERE l.lotteryid='{$lottery['i_id']}' AND l.checked=0 ORDER BY l.t_id ASC");
			$tickets_bought = $DB->get_num_rows();
			while($ticket = $DB->fetch_row($query)) {
				$correct_numbers = 0;
				$correct = 0;
				$numbers_chosen = @explode("|",$ticket['numbers_chosed']);
				$your_numbers = array();
				$array1 = array_count_values($numbers_chosen);
				$array2 = array_count_values($winning_numbers);
				foreach($array1 as $number1 => $count1)
				{
				foreach($array2 as $number2 => $count2)
				{
				if($number2 == $number1 and $count2==$count1)
				$correct_numbers = $correct_numbers + $count2;
				}
				}
				$use = 0;
				$numbers = @implode("|",$winning_numbers);
				echo $correct_numbers;
				echo "<br>";
				echo $lottery['balls'];

				if($correct_numbers == $lottery['balls'])
				{
					foreach($numbers_chosen as $choice => $number) {
					if($winning_numbers[$choice] == $number) {
						$correct++;
					}
					}
					}
				}
				exit;

 

Another weird problem is the $winning_numbers selects a randomize X|X|X number 1-32 for each | seperated.

 

But it should be matching

$ticket['numbers_chosed']

Cause that is from the Lottery ticket I purchased, which is "8|18|3", no idea why that $winning_number code is there when it should be reading off the "8|18|3" instead of grabbing a new generated one?

 

I am probably Missing something, I tried to explain the best I could, I am so close to get this lottery thing done!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.