PHP实现随机发扑克牌
本文实例为大家分享了PHP实现随机发扑克牌的具体代码,供大家参考,具体内容如下
<!doctype html> <html> <!-- 随机发扑克牌 --> <head> <meta charset="UTF-8"> <title>随机发牌</title> <style> div{margin:15px 0} font{border:1px solid #ccc;padding:6px 3px;margin-right:10px} </style> <?php // 建立数组保存的牌组池 $num = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']; $icon = ['♥' => 'red', '♦' => 'red', '♠' => 'black', '♣' => 'black']; //生成扑克牌 $poker = []; foreach ($icon as $iconkey => $iconvalue) { foreach ($num as $value) { $poker[] = "<font style='color:$iconvalue'> {$value} {$iconkey}</font>"; } } shuffle($poker); //打乱数组 ?> </head> <body> <div>玩家A 牌组</div> <?php for ($i = 0; $i < 10; ++$i) { echo current($poker); next($poker); } ?> <div>玩家B 牌组</div> <?php for ($i = 0; $i < 10; ++$i) { echo current($poker); next($poker); } ?> <div>玩家C 牌组</div> <?php for ($i = 0; $i < 10; ++$i) { echo current($poker); next($poker); } ?> </body> </html>
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23