-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop.php
73 lines (63 loc) · 1.25 KB
/
loop.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
<?php
$user1 = [
'name' => 'Victor',
'lang' => 'PHP',
'city' => 'Kiev',
];
$user2 = [
'name' => 'Andrii',
'lang' => 'JavaScript',
'city' => 'Ternopil',
];
$user3 = [
'name' => 'Vlad',
'lang' => 'Ruby',
'city' => 'New York',
];
$users = [
'I am' => $user1,
'My friend' => $user2,
'Obama' => $user3,
];
// echo $users[1]['lang'];
// $i++ => $i = $i + 1
// $i-- => $i = $i - 1
// $count = count($users);
// for ($i = 0; $i < $count; $i++) {
// echo $users[$i]['name'] . '<br>';
// echo $users[$i]['lang'] . '<br>';
// echo $users[$i]['city'] . '<br>';
// }
// foreach ($users as $user) {
// echo $user['name'] . '<br>';
// echo $user['lang'] . '<br>';
// echo $user['city'] . '<br>';
// }
/*
<?php echo $var ?> => <?= $var ?>
*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.heading {
font-size: 20px;
}
.green {
color: #2F9C56;
}
</style>
</head>
<body>
<h1>User list</h1>
<?php foreach ($users as $status => $user) : ?>
<h2 class="heading green"><?= $user['name'] ?></h2>
<p>Status: <?= $status ?></p>
<p>Language: <strong class="green"><?= $user['lang'] ?></strong></p>
<p>City: <strong class="green"><?= $user['city'] ?></strong></p>
<?php endforeach ?>
</body>
</html>