Blogger Information
Blog 21
fans 0
comment 0
visits 10963
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php实现双色球抽奖
Original
554 people have browsed it

代码部分

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>双色球抽奖php</title>
  8. </head>
  9. <body>
  10. <?php
  11. // 1. 生成1-33个红球
  12. $arr = range(1,33);
  13. // 2. 从33个红球中随机取出6个
  14. shuffle($arr);
  15. $res = array_slice($arr, 0, 6);
  16. sort($res);
  17. // 3. 生成一个蓝球, 并追加到中奖数组中
  18. $blue = rand(1,16);
  19. array_push($res,$blue);
  20. // 4. 将中奖号码显示到页面中
  21. echo '<div class ="box">';
  22. foreach ($res as $value) {
  23. printf('<div>%s</div>',$value);
  24. }
  25. echo '</div>';
  26. ?>
  27. <!-- 双色球CSS样式 -->
  28. <style>
  29. .box {
  30. display: grid;
  31. grid-template-columns: repeat(auto-fill, 45px);
  32. grid-auto-rows: 45px;
  33. gap: 5px;
  34. }
  35. .box>div {
  36. font-size:22px;
  37. border-radius: 50%;
  38. display: grid;
  39. place-items: center;
  40. background-color: red;
  41. color: white;
  42. box-shadow: 2px 2px 2px #666;
  43. }
  44. .box>div:last-of-type {
  45. background-color: blue;
  46. }
  47. </style>
  48. </body>
  49. </html>

实现效果

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post