编辑代码

<?php
//------------------------>最小两码差
$formula = array(
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "合值",
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "振幅",
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "再振",
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9"
);

$size = 120;

$numbers = [
            "657","292","703","916","214",
            "634","085","898","141","260",
            "416","333","518","487","606",
            "679","942","104","027","836",
            "710","056","468","638","591",
            "762","486","588","383","409",
            "096","302","379","499","606",
            "261","778","617","131","847",
            "932","428","401","772","475",
            "912","554","490","248","640",
            "004","806","905","585","895",
            "497","368","492","397","405",
            "847","938","476","810","405",
            "928","538","720","385","555",
            "906","748","434","272","778",
            "419","709","781","625","000",
            "657","500","403","417","915",
            "030","338","388","826","022",
            "658","159","135","317","545",
            "649","068","385","542","714",
            "707","953","016","161","370",
            "877","015","752","027","407",
            "841","914","270","954","635",
            "375","206","320","849","621",
            "315","912","120","488","725",
            "809","351","320","431","814",
            "915","204","203","689","645",
            "748","458","113","838","296",
            "598","149","202","916","256",
            "666","267","897","321","838",
            "734","321","718","210","069",
            "923","499","775","969","701",
            "073","503","748","275","636",
            "337","609","808","702"

            ];



function zuSan($accnum){
    $tmpArr = array($accnum[0], $accnum[1], $accnum[2]);
    $tArray = array_unique($tmpArr);
    if(count($tArray) == 3){
        return false;    
    }
    return true;    
}

function zhenFu($lastacc, $accnum){
    $tmpArr0 = array($lastacc[0], $lastacc[1], $lastacc[2]);
    sort($tmpArr0);
    $tmpArr1 = array($accnum[0], $accnum[1], $accnum[2]);
    sort($tmpArr1);
    $lastArr = array($tmpArr0[1]-$tmpArr0[0],$tmpArr0[2]-$tmpArr0[1],$tmpArr0[2]-$tmpArr0[0]);
    $accArr = array($tmpArr1[1]-$tmpArr1[0],$tmpArr1[2]-$tmpArr1[1],$tmpArr1[2]-$tmpArr1[0]);
    $num0 = min($lastArr);
    $num1 = min($accArr);
    $zf = abs($num1 - $num0); 
    if($zf > 9){
        $zf = $zf % 10;
    }
    return $zf;    
}

function zhenFu2($lastacc, $accnum){
    $tmpArr0 = array($lastacc[0], $lastacc[1], $lastacc[2]);
    sort($tmpArr0);
    $tmpArr1 = array($accnum[0], $accnum[1], $accnum[2]);
    sort($tmpArr1);
    $lastArr = array($tmpArr0[1]-$tmpArr0[0],$tmpArr0[2]-$tmpArr0[1],$tmpArr0[2]-$tmpArr0[0]);
    $accArr = array($tmpArr1[1]-$tmpArr1[0],$tmpArr1[2]-$tmpArr1[1],$tmpArr1[2]-$tmpArr1[0]);
    sort($lastArr);
    sort($accArr);
    $num0 = $lastArr[1];
    $num1 = $accArr[1];
    $zf = abs($num1 - $num0); 
    if($zf > 9){
        $zf = $zf % 10;
    }
    return $zf;    
}

function weiZhi($index){
    $msg = "";
    $index = $index;
    for($i=0;$i<10;$i++){
        if($index == $i){
            $msg = $msg . '<td style="background-color: green;">' . $i  .  '</td>';
        }else{
            $msg = $msg . '<td></td>';
        }
    }
    
    return $msg;
}


echo "===>  最近" . $size . "期\n";

echo "              最小两码差";
echo '<table width="0" height="100" border="1" cellpadding="0" cellspacing="0">';
    // 3. 输出表头
echo '<thead><tr><th>' .  '开奖号' . '</th>';
foreach ($formula as $item){
    echo '<th>' . $item . '</th>';
}
echo '</tr></thead>';
// 4. 输出表格内容
echo '<tbody>';
$length = count($numbers);
$bIndex = 0;
if($length >= $size){
    $bIndex = $length - $size;
}
$numbers = array_slice($numbers, $bIndex , $size);
$length2 = count($numbers);
$jisuan = 0;

for ($i=0;$i<$length2;$i++){
    if($i<2){
        continue;
    }
    echo '<tr>';
    $tmpArr = array($numbers[$i][0],$numbers[$i][1],$numbers[$i][2]);
    $acc_num = array_sum($tmpArr);
    $he_num = $acc_num % 10;
    echo '<td>' . $numbers[$i] . '</td>';
    $outputMsg =  weiZhi($he_num);
    echo $outputMsg;

    if($i > 0){
        echo '<td>  </td>';
        $tmpArr1 = array($numbers[$i-1][0],$numbers[$i-1][1],$numbers[$i-1][2]);
        $last_num = array_sum($tmpArr1);
        $total_num1 = abs($acc_num%10 - $last_num%10);
        $outputMsg1 =  weiZhi($total_num1);
        echo $outputMsg1;

        echo '<td>  </td>';
        $tmpArr2 = array($numbers[$i-2][0],$numbers[$i-2][1],$numbers[$i-2][2]);
        $last_num2 = array_sum($tmpArr2);
        $total_num2 = abs($last_num2%10 - $last_num%10);
        $zf2 = abs($total_num2 - $total_num1);
        $outputMsg2 =  weiZhi($zf2);
        echo $outputMsg2;

        echo '<td>  </td>';
        if($i<3){
            $jisuan = $zf2;
            continue;
        }else{
            $zf3 = abs($jisuan - $zf2);
            $outputMsg3 =  weiZhi($zf3);
            echo $outputMsg3;
            $jisuan = $zf2;
        }
    }

    echo '</tr>';
}
echo '</tbody>';

echo '<thead><tr><th>' .  '开奖号' . '</th>';
foreach ($formula as $item){
    echo '<th>' . $item . '</th>';
}
echo '</tr></thead>';
echo '</table>';
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";


echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
?>