-
Notifications
You must be signed in to change notification settings - Fork 0
/
soal_array.php
113 lines (94 loc) · 2.88 KB
/
soal_array.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
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Array</title>
</head>
<body>
<h1>Berlatih Array</h1>
<?php
echo "<h3> Soal 1 </h3>";
/*
SOAL NO 1
Kelompokkan nama-nama di bawah ini ke dalam Array.
Kids : "Mike", "Dustin", "Will", "Lucas", "Max", "Eleven"
Adults: "Hopper", "Nancy", "Joyce", "Jonathan", "Murray"
*/
$kids; // Lengkapi di sini
$adults;
echo "<h3> Soal 2</h3>";
/*
SOAL NO 2
Tunjukkan panjang Array di Soal No 1 dan tampilkan isi dari masing-masing Array.
*/
echo "Cast Stranger Things: ";
echo "<br>";
echo "Total Kids: "; // Berapa panjang array kids
echo "<br>";
echo "<ol>";
echo "<li> $kids[0] </li>";
// Lanjutkan
echo "</ol>";
echo "Total Adults: "; // Berapa panjang array adults
echo "<br>";
echo "<ol>";
echo "<li> $adults[0] </li>";
// Lanjutkan
echo "</ol>";
/*
SOAL No 3
Susun data-data berikut ke dalam bentuk Asosiatif Array didalam Array Multidimensi
Name: "Will Byers"
Age: 12,
Aliases: "Will the Wise"
Status: "Alive"
Name: "Mike Wheeler"
Age: 12,
Aliases: "Dungeon Master"
Status: "Alive"
Name: "Jim Hopper"
Age: 43,
Aliases: "Chief Hopper"
Status: "Deceased"
Name: "Eleven"
Age: 12,
Aliases: "El"
Status: "Alive"
Output:
Array
(
[0] => Array
(
[Name] => Will Byers
[Age] => 12
[Aliases] => Will the Wise
[Status] => Alive
)
[1] => Array
(
[Name] => Mike Wheeler
[Age] => 12
[Aliases] => Dugeon Master
[Status] => Alive
)
[2] => Array
(
[Name] => Jim Hooper
[Age] => 43
[Aliases] => Chief Hopper
[Status] => Deceased
)
[3] => Array
(
[Name] => Eleven
[Age] => 12
[Aliases] => El
[Status] => Alive
)
)
*/
?>
</body>
</html>