本文实例为大家分享了PHP实现随机发扑克牌的具体代码,供大家参考,具体内容如下
随机发牌div{margin:15px 0}
font{border:1px solid #ccc;padding:6px 3px;margin-right:10px}
// 建立数组保存的牌组池
$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[] = " {$value} {$iconkey}";
}
}
shuffle($poker); //打乱数组
?>
玩家A 牌组
echo current($poker);
next($poker);
} ?>
玩家B 牌组
echo current($poker);
next($poker);
} ?>
玩家C 牌组
echo current($poker);
next($poker);
} ?>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持本站。