-
Notifications
You must be signed in to change notification settings - Fork 0
/
library.php
34 lines (30 loc) · 1.01 KB
/
library.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
<?php
$authors = [
['name' => 'Пушкин', 'email' => '[email protected]', 'year' => 1799],
['name' => 'Гоголь', 'email' => '[email protected]', 'year' => 1809],
['name' => 'Тургенев', 'email' => '[email protected]', 'year' => 1818],
];
$books = [
['name' => 'Пиковая дама', 'year' => 1800, 'author' => 0],
['name' => 'Дубровский', 'year' => 1801, 'author' => 0],
['name' => 'Вий', 'year' => 1835, 'author' => 1],
['name' => 'Мертвые души', 'year' => 1835, 'author' => 1],
['name' => 'Дворянское гнездо', 'year' => 1858, 'author' => 2],
];
/**
* Выводим список авторов.
*/
foreach ($authors as $author) {
echo $author['name'].' - ';
echo $author['email']. ' - ';
echo $author['year'].'<br>';
}
echo '<hr>';
/**
* Выводим списко книг.
*/
foreach ($books as $book) {
echo $book['name'].' - ';
echo $authors[$book['author']]['name'].' - ';
echo $book['year'].'<br>';
}