PHP 作业2.9 双色球

要求


php随机生成8个不同的随机数


效果图


在这里插入图片描述


index.php代码


<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title>双色球33-16</title>
  <style>
    .main {
      border: 7px dotted #00bcff;
      width: 999px;
      margin: 222px auto;
      padding: 28px;
      font-size: 28px;
    }

    h1 {
      text-align: center;
    }

    button {
      height: 50px;
      display: block;
      margin: 20px auto;
    }

    button:hover {
      background-color: greenyellow;
    }

    /* 第一种背景颜色 */
    .bg1 {
      display: inline-block;
      background: red;
      border-radius: 100%;
      height: 100px;
      width: 100px;
      margin-right: 10px;
      text-align: center;
      line-height: 100px;
      font-size: 50px;
      color: greenyellow;
      font-weight: bold;
      /* background: radial-gradient(circle at 30% 35%,
          #ddd,
          blue 0%,
          black 120%); */
      background: radial-gradient(circle at 35% 20%,
          #ddd,
          red,
          black);
    }


    /* 第二种背景颜色 */
    .bg2 {
      display: inline-block;
      background: blue;
      border-radius: 100%;
      height: 100px;
      width: 100px;
      /* margin: 10px; */
      text-align: center;
      line-height: 100px;
      font-size: 50px;
      color: greenyellow;
      font-weight: bold;
      background: radial-gradient(circle at 35% 20%,
          #ddd,
          blue,
          black);
    }
  </style>
</head>

<body>
  <?php
  //设置红球数组范围:1-36
  $red = range(1, 33);
  //随机从数组抽取8个数字
  $reds = array_rand($red, 8);
  //打乱排序
  shuffle($reds);
  //设置蓝色球数组范围
  $blue = range(1, 16);
  //随机选取一个的索引下标
  $blues = array_rand($blue, 1);
  //把下标转换为所需要的值
  $b = $blue[$blues];
  //访问数组索引
  ?>

  <div class="main">
    <h1>双色球33(7)+16(1)</h1>

    <button onclick="sx()">开始摇号抽奖</button>

    <div id="red">
      <?php
      foreach ($reds as $r) {
        echo "<div class='bg1'>" . $red[$r] . "</div>";
      }
      ?>


      <div class="bg2" id="blue">
        <?php
        echo $b;
        ?>
      </div>

    </div>
    <script>
      function sx() {
        location.reload();
      }
    </script>


</body>

</html>

效果图2


在这里插入图片描述


index1.php


<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title>体育彩票367</title>
  <style>
    .main {
      border: 7px dotted #00bcff;
      width: 999px;
      margin: 222px auto;
      padding: 28px;
      font-size: 28px;
    }

    h1 {
      text-align: center;
    }

    button {
      height: 50px;
      display: block;
      margin: 20px auto;
    }

    button:hover {
      background-color: greenyellow;
    }

    /* 第一种背景颜色 */
    .bg1 {
      display: inline-block;
      background: blue;
      border-radius: 100%;
      height: 100px;
      width: 100px;
      /* margin: 10px; */
      text-align: center;
      line-height: 100px;
      font-size: 50px;
      color: greenyellow;
      font-weight: bold;
      /* background: radial-gradient(circle at 30% 35%,
          #ddd,
          blue 0%,
          black 120%); */
      background: radial-gradient(circle at 35% 20%,
          #ddd,
          blue,
          black);
    }

    /* 第二种背景颜色 */
    .bg2 {
      background-color: red;
    }

    .ball {
      display: inline-block;
      width: 100%;
      height: 100%;
      margin: 0;
      border-radius: 50%;
      position: relative;

      background-size: 100%;
    }

    .ball:before {
      content: "";
      position: absolute;
      top: 0%;
      left: 5%;
      width: 90%;
      height: 90%;
      border-radius: 50%;
      background: radial-gradient(circle at 30% 0px,
          #ffffff,
          rgba(255, 255, 255, 0) 58%);
      -webkit-filter: blur(5px);
      z-index: 2;
    }

    .ball:after {
      content: "";
      position: absolute;
      border-radius: 100%;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      background: radial-gradient(circle at 50% 30%,
          rgba(245, 237, 48, 0),
          rgba(200, 190, 20, 0.2) 50%,
          #575300 100%);
    }

    .ball .shadow {
      position: absolute;
      width: 100%;
      height: 100%;
      background: radial-gradient(circle,
          rgba(0, 0, 0, 0.4),
          rgba(0, 0, 0, 0.1) 40%,
          rgba(0, 0, 0, 0) 50%);
      -webkit-transform: rotateX(90deg) translateZ(-160px);
      transform: rotateX(90deg) translateZ(-160px);
      z-index: 1;
    }

    .stage {
      width: 100px;
      height: 100px;
      display: inline-block;
      margin: 10px;
      text-align: center;
      line-height: 100px;
      font-size: 50px;
      font-weight: bold;
      -webkit-perspective: 1200px;
      -moz-perspective: 1200px;
      -ms-perspective: 1200px;
      -o-perspective: 1200px;
      perspective: 1200px;
      -webkit-perspective-origin: 50% 50%;
      -moz-perspective-origin: 50% 50%;
      -ms-perspective-origin: 50% 50%;
      -o-perspective-origin: 50% 50%;
      perspective-origin: 50% 50%;
    }
  </style>
</head>

<body>
  <?php
  //设置数组范围:1-36
  $num = range(1, 33);
  //随机从数组抽取8个数字
  $nums = array_rand($num, 8);
  //打乱排序
  shuffle($nums);


  //访问数组索引
  ?>

  <div class="main">
    <h1>体育彩票367</h1>

    <button onclick="sx()">开始摇号抽奖</button>

    <div class="ball stage bg2">
      <?php
      echo $num[$nums[0]];
      ?>
    </div>
    <div class="ball stage bg2">
      <?php
      echo $num[$nums[1]];
      ?>
    </div>
    <div class="ball stage bg2">
      <?php
      echo $num[$nums[2]];
      ?>
    </div>
    <div class="ball stage bg2">
      <?php
      echo $num[$nums[3]];
      ?></div>
    <div class="ball stage bg2">
      <?php
      echo $num[$nums[4]];
      ?>
    </div>
    <div class="ball stage bg2">
      <?php
      echo $num[$nums[5]];
      ?>
    </div>
    <div class="ball stage bg2">
      <?php
      echo $num[$nums[6]];
      ?>
    </div>

    <div class="bg1">
      <?php
      echo $num[$nums[7]];
      ?>
    </div>

  </div>
  <script>
    function sx() {
      location.reload();
    }
  </script>


</body>

</html>
php双色球在线机选程序V1.0(支持复式机选) 运行环境: php5.0及以上 安装方法: 上传所有文件到服务器. 本人平生也经常购买福彩双色球,本人不相信所谓的规律,我只相信运气。 所以每次选号都是直接机选。后来时间长了,我觉得福彩的那个售票系统的机 选程序不够强大,应该也不是严格意义上的机选。所以决定用php写一个机选 的程序,于是自已起草了程序的基本需求如下: 分析双色球的玩法规则: 其实就是红色球和蓝色球组成的一组号码,红色球的 数字范围为1~33,蓝色球的范围为1~16,所以机选双色球的程序要考虑以下内容 : 1. 先机选出红色球部份,也就是在数字1~33之间,随机取6个数字,而且这6个 数字不能重复,最后对这6个数字进行从小到大进行排序。这时候,我们已经产 生了双色球红球部份的6个号码。当然,如果是复式机选,红球的个数则是 7~20个,所以如果是复式机选的话,红色球的个数根据具体的个数在1~33中产 生具体个数的红色号码. 2.然后再机选出蓝色球部份,也就是在数字1~16范围内,随机取1个数字.当然 如果是复式机选,则相应产生多个蓝色球,也就是在数字1~16范围内,产生多 个不重复的号码 3.组合机选出来的红色球和蓝色球的号码,合并后进行输出。这样一注双色球 就产生了。 程序的核心算法和原理: 1.机选的实现: 红色球部份,先将1~33这33个常数放在一个数组中,也就是这个数组中有33个 数组元素,然后将这个数组元素的排列,使用函数将其随机打乱,最后截取某 一段。 2.用户单式和复式的判断,以及用户注数的判断使用GET模式的URL传值进行赋 值。 本程序原是本人自用的程序,如果错误或BUG,请真指正。现将本程序进行开 放源代码,方便有需要有人进行使用和改进。 程序演示地址: http://www.12580.info/cp/ssq 程序的下载地址: 说明:如对CSS有造诣的同事,可以帮忙修改一下表单和网页样式,使其美观。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值