Sfoglia il codice sorgente

去掉重复的数

pengchanglu 2 anni fa
parent
commit
4976558d4e
1 ha cambiato i file con 10 aggiunte e 2 eliminazioni
  1. 10 2
      application/admin/controller/lottery/Ticket.php

+ 10 - 2
application/admin/controller/lottery/Ticket.php

@@ -44,8 +44,16 @@ class Ticket extends Backend
               $code = [];//初始化 35*35插入
               for ($l=$k+1; $l<=34; $l++) {
                 for ($m=$l+1; $m<=35; $m++) {
-                    $arr['code'] = "$i-$j-$k-$l-$m";
-                    $code[] =  $arr;
+
+
+                    $combination = [$i, $j, $k, $l, $m];
+                    sort($combination); // 将组合数组升序排序
+                    $unique_combination = array_unique($combination); // 去掉重复的数字
+                    if (count($unique_combination) === 5) { // 确保选出的数字数量为5个
+                        $arr['code'] = "$i-$j-$k-$l-$m";
+                        $code[] =  $arr;
+                    }
+                    
                 }
                 //$this->model->allowField(true)->saveAll($code);
                 //exit;