Part on Associative Arrays finished

This commit is contained in:
Patryk Hegenberg 2022-12-10 14:25:53 +01:00
parent 7f7de38781
commit 10571ef7db
2 changed files with 17 additions and 10 deletions

View file

@ -10,16 +10,24 @@
<body>
<?php
$books = [
"Do Androids Dream of Electric Sheep",
"The Langoliers",
"Hail Mary"
[
'name' => 'Do Androids Dream of Electric Sheep',
'author' => 'Philip K. Dick',
'purchaseUrl' =>'http://example.com'
],
[
'name' => 'Projekt Hail Mary',
'author' => 'Ady Weir',
'purchaseUrl' => 'http://example.com'
]
];
?>
<h1>Recommended Book</h1>
<ul>
<?php foreach($books as $book) :?>
<li><?php echo $book; ?></li>
<?php endforeach; ?>
</ul>
<?php foreach($books as $book): ?>
<li>
<a href="<?= $book['purchaseUrl']; ?>">
<?= $book['name']; ?>
</a>
</li>
<?php endforeach; ?>
</body>
</html>

View file

@ -1,5 +1,4 @@
body {
display: grid;
height: 100vh;
margin: 0;
font-family: sans-serif;