-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray_stuff.php
104 lines (91 loc) · 1.71 KB
/
array_stuff.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
$multiCity = array(
array('City', 'Country', 'Continent'),
array('Tokyo', 'Japan', 'Asia'),
array('Mexico City','Mexico', 'North America'),
array('New York City', 'USA', 'North America'),
array('Mumbai', 'India', 'Asia'),
array('Seoul', 'Korea', 'Asia'),
array('Shanghai', 'China', 'Asia'),
array('Lagos', 'Nigeria', 'Africa'),
array('Buenos Aires', 'Argentina', 'South America'),
array('Cairo', 'Egypt', 'Africa'),
array('London', 'UK','Europe')
);
?>
<html>
<head>
<title>Multi-dimensional Array</title>
<style type="text/css">
td,th {
width: 8em;
border: 1px solid black;
padding-left: 4px;
}
th {
text-align: center;
}
table {
border-collapse: collapse;
border: 1px solid black;
}
</style>
</head>
<body>
<h2>
Auflistung Array<br />
</h2>
<table>
<thead>
<tr>
<?php
foreach ($multiCity[0] as $value) {
echo "<th>" . $value . "</th>";
}
?>
</tr>
</thead>
<?php
for ($i = 1; $i < count($multiCity); $i++) {
echo "<tr>";
foreach ($multiCity[$i] as $value) {
echo "<td>" . $value . "</td>";
}
echo "</tr>";
}
?>
</table>
<h2>
Auflistung der Städte in Asien<br />
</h2>
<table>
<thead>
<tr>
<?php
foreach ($multiCity[0] as $value) {
echo "<th>" . $value . "</th>";
}
?>
</tr>
</thead>
<?php
foreach ($multiCity as $multiArray) {
if (strcmp($multiArray[2],"Asia") == 0) {
echo "<tr>";
foreach ($multiArray as $value) {
echo "<td>" . $value . "</td>";
}
echo "</tr>";
}
}
?>
</table>
<h2>
Auflistung der Kontinente, sowie die Zahl der Länder darin (im
Array)<br />
</h2>
<h2>
Auflistung nach Länder A-Z <br />
</h2>
</body>
</html>