Jump to content

Recommended Posts

Hi All

 

I wish to create an Associative array of a deck of cards,

 

the user $_GET's from radio buttons a sequences of 3 colors, red, red, black for example.

 

the program also picks a sequences of colors

 

while there are cards in the deck , i wish to write a program that records which sequence

 

is encountered the most, and out put the winner by how much ??

 

 

$suits = array ( "Spades", "Hearts", "Clubs", "Diamonds");

 

$cards = array ("2", "3", "4", "5", "6", "7", "8","9", "10", "Jack", "Queen", "King", "Ace");

 

$deck = array();

 

foreach ($suits as $suit)

{

foreach ($cards as $card)

{

$deck[ ] = array ("Card" => $card, "Suit" => $suit);

}

}

 

how should i continue and how to attach colors to this array ??

 

Thanks for any advice offered ☺

Associate the suits with their colors. You could

$suits = array ( array ( "Spades", "black" ), array ( "Hearts", "red" ), ... );

or

$suits = array ( "black" => array ( "Spades", "Clubs "), ... );

or

$suits = array ( "Spades" => "black", "Hearts" => "red", ... );

Edited by requinix
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.