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> <body>
<?php <?php
$books = [ $books = [
"Do Androids Dream of Electric Sheep", [
"The Langoliers", 'name' => 'Do Androids Dream of Electric Sheep',
"Hail Mary" '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): ?> <?php foreach($books as $book): ?>
<li><?php echo $book; ?></li> <li>
<a href="<?= $book['purchaseUrl']; ?>">
<?= $book['name']; ?>
</a>
</li>
<?php endforeach; ?> <?php endforeach; ?>
</ul>
</body> </body>
</html> </html>

View file

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