-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge26.php
More file actions
40 lines (32 loc) · 958 Bytes
/
challenge26.php
File metadata and controls
40 lines (32 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$myAnimals = array("mamal 1" => "horse", "mamal 2" => "cow", "mamal 3" => "pig", "rodent 1" => "mouse", "fish 1" => "shark", "rodent 2" => "rat", "mamal 4" => "donkey", "mamal 5" => "whale", "mamal 6" => "cheetah", "mamal 7" => "cat", "mamal 8" => "dog", "fowl 1" => "chicken");
function printArray($array, $col)
{
$counter = 1;
echo "<table border = '1'>\n";
echo "<tr>\n";
foreach($array as $key => $temp)
{
echo "<td>$key -- $temp</td>";
if ($counter == count($array))
{
echo "\n</tr>\n</table>\n";
}
elseif ($counter % $col == 0)
{
echo "\n</tr>\n<tr>\n";
}
$counter++;
}
}
printArray($myAnimals, 4);
?>
</body>
</html>