晴明的博客园 GitHub      CodePen      CodeWars     

[PHP]双色球

<?php
    $red_num = range(1,33);
    $keys = array_rand($red_num,6);    
    shuffle($keys);    
    foreach($keys as $v){
        $red = $red_num[$v]<10 ? ('0'.$red_num[$v]) : ($red_num[$v]);
        echo '<span style="color:white;width:50px;height:50px;border-radius:50%;background:red;display:inline-block;text-align:center;line-height:50px;">'.$red.'</span>';
    }
    $blue_num = rand(1,16);
    $blue = $blue_num<10 ? ('0'.$blue_num) : ($blue_num);
    echo '<span style="color:white;width:50px;height:50px;border-radius:50%;background:blue;display:inline-block;text-align:center;line-height:50px;">'.$blue.'</span>';
?>

posted @ 2015-11-15 23:52  晴明桑  阅读(470)  评论(0编辑  收藏  举报