This deck class, and co-operating card class, will work for any website or command line project you may be putting together with PHP. Simply include the files, and build a new deck, passing an integer with the number of decks you wish to use.
<?php
include_once('deck.php');
include_once('card.php');
$deck = new deck(1);
for($i = 1; $i <= 5; $i++) {
$card = $deck -> dealCard();
echo $card -> getCardLetter() . ' ' . $card -> getCardSuitName() . "<br />";
}
This will print out a result like the following:
4 Spade
K Heart
7 Club
K Spade
6 Club
Questions & Comments