// PlayCards & deal /* Deal from a random deak of playing cards, using HTML symbols (and colors) for the suits */ function PlayCards($x=1,$y=1) { $suits = array('', '', '', '', ); $vals = array('A', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K'); $pack = array(); foreach ($vals as $v) { foreach ($suits as $s) { $pack[] = "$s$v"; } } shuffle ($pack); $hands = deal ($pack, $x, $y); // deal four hands of 5 cards foreach ($hands as $cards) { $lcnt=0; foreach ($cards as $c) { if ($lcnt++ != 0) { echo ", "; } echo "$c"; } echo '
'; } } function deal (&$pack, $numhands, $cards_per_hand) { $hands = array(); if ($numhands*$cards_per_hand > 52) return $hands; $temp = array_slice ($pack, 0, $numhands*$cards_per_hand); $hands = array_chunk($temp, $cards_per_hand); return $hands; }