$deckLength = $this->cards->length(); $index = rand(0, $deckLength - 1); $this->cards->swapToHead($index); for ($i = 0; $i < $deckLength - 1; $i++) { $index = rand($i, $deckLength - 2); $this->cards->swapToHead($index); } } public function dealCard() { $temp = $this->cards->head; $this->cards->head = $this->cards->head->next; $temp->next = null; return $temp; } } $deck1 = new Deck(); var_dump($deck1->cards); $deck1->cards->printValues(); $deck1->shuffleCards(); var_dump($deck1->cards); var_dump($deck1->dealCard()); var_dump($deck1->dealCard()); var_dump($deck1->dealCard()); var_dump($deck1->dealCard()); $deck1->shuffleCards(); var_dump($deck1->cards); echo "" . $deck1->cards->length() . "cards in the deck"; $deck1->resetDeck(); var_dump($deck1->cards); echo "" . $deck1->cards->length() . "cards in the deck";