Deck Parameters

Top  Previous  Next

A deck parameter lists out all 52 cards in a standard set of cards, in a fixed order.

 

$d=deck()

 

$d will now contain

 

A♠ 2♠ 3♠ 4♠ 5♠ 6♠ 7♠ 8♠ 9♠ 10♠ J♠ Q♠ K♠ A♥ 2♥ 3♥ 4♥ 5♥ 6♥ 7♥ 8♥ 9♥ 10♥ J♥ Q♥ K♥

A♣ 2♣ 3♣ 4♣ 5♣ 6♣ 7♣ 8♣ 9♣ 10♣ J♣ Q♣ K♣ A♦ 2♦ 3♦ 4♦ 5♦ 6♦ 7♦ 8♦ 9♦ 10♦ J♦ Q♦ K♦

 

This order does not change so $d[15] will always be the two of hearts. If you want a shuffled deck of cards, you need to create a second parameter which shuffles the first.

 

$d=deck()

$s=shuffle($d)