Just a suggestion, but you're implementation of the cards seems overly complicated. It should be easy to do a check for pairs and fullhouses, and what not.
start with a class called Card (this is from memory so there may be syntax errors and what not):
class Card {
var $index;
var $suit; // 0 to 3 you can define which is what
var $value; // 0 to 12, aces are 12 or 0 or you can actually put their value this is just quick and dirty
function Card($index) {
$this->index = index;
$this->suit = index % 13;
$this->value = index % 4;
}
}
and then you can add a class called Hand and it would tabulate the result
class Hand {
$values = array(); // value of cards
$suits = array();
$cards = array();
function Hand($cards) {
$this->cards = $cards;
}
function checkResult() {
foreach ($this->cards as $card) {
$values[$card->value]++;
$suits[$card->suit]++;
}
}
function getPairs() {
$pairs = array();
foreach ($values as $key=>$value) {
if ($value == 2)
$pairs[] = $value;
}
return $pairs;
}
function getThreeOfAKind() {
$result = false;
foreach ($values as $key=>$value) {
if ($value == 3)
return $key;
}
return false;
}
}
then you can call
$hand = new Hand($arrayOfCards);
$hand->checkResult();
echo "This hand has this many pairs: " + count($hand->getPairs());
echo "Full house? " + (count($hand->getPairs()) + $hand->getThreeOfAKind !== false);
It'd be easy to implement the rest of the card checks in the Hand class:
function checkFlush() {
foreach ($this->suits as $suit=>$num) {
if ($num == 5)
return $suit;
}
return false;
}
etc... I didn't mean to write so much code, sorry, lol