Chapter 11 - Complete exercises 11.1 and 11.2 on page 339, along with the exerci
ID: 3833202 • Letter: C
Question
Chapter 11 - Complete exercises 11.1 and 11.2 on page 339, along with the exercise below 2 dimensional Array Exercise In this exercise you will be creating a 2 dimensional array. 1. Create a web page titled: array_excercise.php 2. Creating a table that displays all the cards in a standard deck of cards. This is 52 cards with 2-10, J, Q, K, and A. 3. The first dimensional represents the Card Value and the second dimensional are going to be the suites. 4. Create an array for the four suites which includes all card values as shown below $diamonds = array("2D","3D","4D","5D","6D","7D","8D","9D","10D","JD","QD","KD","AD"); //create arrays for spades, hearts, and clubs. 5. Create a second array: $cards = array($diamonds, $spades, $hearts, $clubs); 6. Create a table that displays each of the cards by suite. An example is below of the first 3 cols. All 13 columns should be displayed. Diamonds Spades Hearts Clubs
Explanation / Answer
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Array Exercise</title>
<link rel="stylesheet" type="text/css" href="common.css" />
</head>
<body>
<h2>Cards</h2>
<?php
$diamonds=array("2D","3D","4D","5D","6D","7D","8D","9D","10D","JD","QD","KD","AD");
$spades=array("2S","3S","4S","5S","6S","7S","8S","9S","10S","JS","QS","KS","AS");
$hearts=array("2H","3H","4H","5H","6H","7H","8H","9H","10H","JH","QH","KH","AH");
$clubs=array("2C","3C","4C","5C","6C","7C","8C","9C","10C","JC","QC","KC","AC");
$cards = array($diamonds, $spades, $hearts, $clubs);
echo "<table border='1' cellpadding='5px'><th>Diamonds</th><th>Spades</th><th>Hearts</th><th>Clubs</th>";
for($i=0;$i<13;$i++)
{
echo"<tr>";
for($j=0;$j<4;$j++)
{
echo "<td>".$cards[$j][$i]."</td>";
}
echo"</tr>";
}
echo "</table>";
?>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.