Monkuar Posted January 25, 2012 Share Posted January 25, 2012 $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 More sharing options...
joe92 Posted January 25, 2012 Share Posted January 25, 2012 $correct_numbers += $count2; Is equivalent to $correct_numbers = $correct_numbers + $count2; Link to comment https://forums.phpfreaks.com/topic/255748-somone-tell-me-whats-going-on-here-lol/#findComment-1311034 Share on other sites More sharing options...
Monkuar Posted January 25, 2012 Author Share Posted January 25, 2012 $correct_numbers += $count2; Is equivalent to $correct_numbers = $correct_numbers + $count2; ty anyone else gonna chime in? Link to comment https://forums.phpfreaks.com/topic/255748-somone-tell-me-whats-going-on-here-lol/#findComment-1311037 Share on other sites More sharing options...
trq Posted January 25, 2012 Share Posted January 25, 2012 With what? Do you not understand what: $correct_numbers = $correct_numbers + $count2; does? Link to comment https://forums.phpfreaks.com/topic/255748-somone-tell-me-whats-going-on-here-lol/#findComment-1311040 Share on other sites More sharing options...
Monkuar Posted January 25, 2012 Author Share Posted January 25, 2012 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! Link to comment https://forums.phpfreaks.com/topic/255748-somone-tell-me-whats-going-on-here-lol/#findComment-1311045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.