JSON Info ophalen vanaf website NS
Code (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
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
<?php echo "<table>" ?>
<tr>
<td style="width: 75px;"><b>Vertrek</b></td>
<td style="width: 400px;"><b>Naar/Opmerkingen</b></td>
<td style="width: 50px; text-align:center"><b>Spoor</b></td>
<td style="width: 100px;"><b>Trein</b></td>
</tr>
<?php
foreach ($data_departures as $key => $value) {
$date = new DateTimeImmutable($value['plannedDateTime']);
$PlannedDateTime = $value['plannedDateTime'];
$ActualDateTime = $value['actualDateTime'];
$Direction = $value['direction'];
$PlannedTrack = $value['plannedTrack'];
$ActualTrack = $value['actualTrack'];
$TrainType = $value['product']['longCategoryName'];
$Canceled = $value['cancelled'];
$Messages = $value['messages'];
$RouteStations = array();
foreach ("???" as $key => $value)
{
array_push($RouteStations, $value);
}
empty($RouteStations);
?>
<tr>
<td><h3><?php echo $date->format('H:i');?></h3></td>
<td><h3><?php echo $Direction . '</h3>' . "Via " . implode(", ",$RouteStations); ?</td>
<td style="text-align:center"><h3>[code]<?php echo $ActualTrack;?><h3></td>
<td><h3><?php echo $TrainType;?><h3></td>
</tr>
<?php } echo "</table>"; ?>
<tr>
<td style="width: 75px;"><b>Vertrek</b></td>
<td style="width: 400px;"><b>Naar/Opmerkingen</b></td>
<td style="width: 50px; text-align:center"><b>Spoor</b></td>
<td style="width: 100px;"><b>Trein</b></td>
</tr>
<?php
foreach ($data_departures as $key => $value) {
$date = new DateTimeImmutable($value['plannedDateTime']);
$PlannedDateTime = $value['plannedDateTime'];
$ActualDateTime = $value['actualDateTime'];
$Direction = $value['direction'];
$PlannedTrack = $value['plannedTrack'];
$ActualTrack = $value['actualTrack'];
$TrainType = $value['product']['longCategoryName'];
$Canceled = $value['cancelled'];
$Messages = $value['messages'];
$RouteStations = array();
foreach ("???" as $key => $value)
{
array_push($RouteStations, $value);
}
empty($RouteStations);
?>
<tr>
<td><h3><?php echo $date->format('H:i');?></h3></td>
<td><h3><?php echo $Direction . '</h3>' . "Via " . implode(", ",$RouteStations); ?</td>
<td style="text-align:center"><h3>[code]<?php echo $ActualTrack;?><h3></td>
<td><h3><?php echo $TrainType;?><h3></td>
</tr>
<?php } echo "</table>"; ?>
Gewijzigd op 23/06/2024 16:17:45 door Donovan -
$RouteStations = $value['routeStations'];
En dan kan je die foreach doorlopen op $RouteStations.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
foreach ($data_departures as $key => $value) {
$Date = new DateTimeImmutable($value['plannedDateTime']);
$PlannedDateTime = $value['plannedDateTime'];
$ActualDateTime = $value['actualDateTime'];
$Direction = $value['direction'];
$PlannedTrack = $value['plannedTrack'];
$ActualTrack = $value['actualTrack'];
$TrainType = $value['product']['longCategoryName'];
$Canceled = $value['cancelled'];
$Messages = $value['messages'];
$RouteStation = $value['routeStations'];
$RouteStationArray = array();
$RouteStations = implode(", ", $RouteStationArray);
foreach ($RouteStation as $key => $Value)
{
array_push($RouteStationArray, $Value);
}
empty($RouteStationsArray);
$Date = new DateTimeImmutable($value['plannedDateTime']);
$PlannedDateTime = $value['plannedDateTime'];
$ActualDateTime = $value['actualDateTime'];
$Direction = $value['direction'];
$PlannedTrack = $value['plannedTrack'];
$ActualTrack = $value['actualTrack'];
$TrainType = $value['product']['longCategoryName'];
$Canceled = $value['cancelled'];
$Messages = $value['messages'];
$RouteStation = $value['routeStations'];
$RouteStationArray = array();
$RouteStations = implode(", ", $RouteStationArray);
foreach ($RouteStation as $key => $Value)
{
array_push($RouteStationArray, $Value);
}
empty($RouteStationsArray);
Gewijzigd op 24/06/2024 13:05:22 door Donovan -
Kijk eens met var_dump($RouteStation); wat het precies is?