我有2个阵列。任务是创建多个列。首先是一个名为" Naam",然后" Rugnummers"然后"目标"。这些列需要填充其中的这两个数组的信息。首先是玩家的价值,然后是目标或玩家的关键(两者都相同),然后是目标的价值。这是两个数组。
<?php
//Opdracht 15
$goals = [
3 => 1,
5 => 5,
6 => 0,
7 => 2,
9 => 0,
12 => 4,
14 => 1,
17 => 3,
18 => 1,
19 => 0,
21 => 5,
22 => 0,
23 => 2,
24 => 3,
28 => 1,
30 => 0
];
$players = [
3 => 'Hendrik Leegsta',
5 => 'Jan Hilverda',
6 => 'Hans Worst',
7 => 'Steven Sterk',
9 => 'Willy Wortel',
12 => 'Flip Flierefluiter',
14 => 'Louis Visser',
17 => 'Aram Harakisjoen',
18 => 'Vladimir de Groot',
19 => 'Thomes Thijssen',
21 => 'Arie van der Linde',
22 => 'Ruben Leegstra',
23 => 'Stijn Voorst',
24 => 'Louis Finn',
28 => 'Jürgen Ultz',
30 => 'Giel de Vries'
];
?>
?>
<html>
<style>
table, th, td{
border: 1px solid black;
border-collapse: collapse;
}
</style>
<table>
<tr>
<th>Naam</th>
<th>Rugnummer</th>
<th>Doelpunten</th>
</tr>
<?php foreach ($players as $backnumber => $names) {?>
<tr>
<td> <?php echo $names;?> </td>
<td><?php echo $backnumber;?> </td>
</tr>
<?php } ?>
<?php foreach ($goals as $backnumbers => $scores) { ?>
<tr>
<td><?php echo $scores;?> </td>
</tr>
<?php } ?>
</tr>
</table>
</html>
答案 0 :(得分:0)
<?php
//Opdracht 15
$goals = [
3 => 1,
5 => 5,
6 => 0,
7 => 2,
9 => 0,
12 => 4,
14 => 1,
17 => 3,
18 => 1,
19 => 0,
21 => 5,
22 => 0,
23 => 2,
24 => 3,
28 => 1,
30 => 0
];
$players = [
3 => 'Hendrik Leegsta',
5 => 'Jan Hilverda',
6 => 'Hans Worst',
7 => 'Steven Sterk',
9 => 'Willy Wortel',
12 => 'Flip Flierefluiter',
14 => 'Louis Visser',
17 => 'Aram Harakisjoen',
18 => 'Vladimir de Groot',
19 => 'Thomes Thijssen',
21 => 'Arie van der Linde',
22 => 'Ruben Leegstra',
23 => 'Stijn Voorst',
24 => 'Louis Finn',
28 => 'Jürgen Ultz',
30 => 'Giel de Vries'
];
?>
<html>
<style>
table, th, td{
border: 1px solid black;
border-collapse: collapse;
}
</style>
<?php echo "<table>"; ?>
<?php echo "<tr><th>Naam</th><th>Nummer</th><th>Goals</th></tr>"; ?>
<?php foreach($players as $playerid => $naam){ ?>
<?php echo "<tr>"; ?>
<?php $goalcount = $goals[$playerid]; ?>
<?php echo "<td>$naam</td><td>$playerid</td><td>$goalcount</td>"; ?>
<?php echo "</tr>";?>
<?php } ?>
</table>
</html>