编辑代码

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

$size = 120;

$numbers = [
            "512","274","469","524","065",
            "470","623","955","863","741",
            "710","783","861","449","253",
            "156","086","274","409","096",
            "749","199","077","249","926",
            "766","465","292","710","245",
            "390","227","931","388","699",
            "795","275","833","172","827",
            "086","684","221","060","248",
            "900","983","419","342","718",
            "621","192","839","989","911",
            "426","462","521","364","571",
            "816","372","055","949","666",
            "435","516","336","169","966",
            "296","579","654","539","603",
            "067","754","095","672","802",
            "789","386","525","726","778",
            "542","867","536","384","158",
            "722","280","306","910","167",
            "964","765","951","541","593",
            "964","843","977","509","278",
            "371","483","214","305","317",
            "056","392","928","108","672",
            "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"
            ];



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);
for ($i=0;$i<$length2;$i++){
    //5. 输出一行数据
    echo '<tr>';

    $tmpArr = array($numbers[$i][0],$numbers[$i][1],$numbers[$i][2]);
    sort($tmpArr);
    $tmpKua = array($tmpArr[1]-$tmpArr[0],$tmpArr[2]-$tmpArr[1],$tmpArr[2]-$tmpArr[0]);
    $minKua = min($tmpKua);    
    echo '<td>' . $numbers[$i] . '</td>';
    $outputMsg =  weiZhi($minKua);
    echo $outputMsg;

    if($i > 0){
        echo '<td></td>';
        $zf = zhenFu($numbers[$i-1],$numbers[$i]);
        $outputMsg1 =  weiZhi($zf);
        echo $outputMsg1;
    }

    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 "              中间两码差";
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);
for ($i=0;$i<$length2;$i++){
    //5. 输出一行数据
    echo '<tr>';

    $tmpArr = array($numbers[$i][0],$numbers[$i][1],$numbers[$i][2]);
    sort($tmpArr);
    $tmpKua = array($tmpArr[1]-$tmpArr[0],$tmpArr[2]-$tmpArr[1],$tmpArr[2]-$tmpArr[0]);
    sort($tmpKua);
    $minKua = $tmpKua[1];    
    echo '<td>' . $numbers[$i] . '</td>';
    $outputMsg =  weiZhi($minKua);
    echo $outputMsg;

    if($i > 0){
        echo '<td></td>';
        $zf = zhenFu2($numbers[$i-1],$numbers[$i]);
        $outputMsg1 =  weiZhi($zf);
        echo $outputMsg1;
    }

    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";
?>