The result of this code is the first data in the table, following the table.
<style> .table { width: 100%; margin-bottom: 20px; } table { max-width: 100%; background-color: transparent; border-collapse: collapse; border-spacing: 0; } tbody { display: table-row-group; vertical-align: middle; border-color: inherit; } tr { display: table-row; vertical-align: inherit; border-color: inherit; } .table th, .table td { padding: 8px; line-height: 20px; text-align: left; vertical-align: top; border-top: 1px solid #dddddd; } user agent stylesheet td, th { display: table-cell; vertical-align: inherit; } td{width:150px;} </style> Somewhere there is an error in the code, and here is where.
<table class="table"><tbody><tr><td>Рейсы</td><td>Отправление</td><td>Прибытие</td><td>Дни курсирования</td></tr><tr> <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://api.rasp.yandex.net/v1.0/schedule/?apikey=*******&format=json&uid=038AA_tis&station=s9623404&lang=ru&thread=false"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); $response = curl_exec($ch); curl_close($ch); $json=json_decode($response,true); ?> <?php foreach ($json['schedule'] as $schedule): ?> <td><?= $schedule['thread']['short_title']; ?></td> <td><?= $schedule['departure_time']; ?></td><td> <?= $schedule['arrival_time'] ? $schedule['arrival_time'] : 'Не указано'; ?></td> <td> <?= $schedule['days']; ?></td></tr> </tbody></table> <?php endforeach; ?>