Answer the question
In order to leave comments, you need to log in
Why is data not being collected from the API?
There is a code
<?php
$json= curl_init();
$json=json_decode($response,true);
$json=end($json['data']);
foreach($json as $val) { ?>
<?
$mapping = json_decode(file_get_contents('http://site.com/airlines/airlines.json'));
$name = '';
$code = $val['destination'];
foreach ($mapping as $item) {
if ($item->iata == $code) {
$name = $item->name;
$departure = $item->departure_at;
break;
}
}
?>
<div style="background:#ffffff; color:#008BE0!important;font-weight:bold;">Вылет: <?=$val['departure_at']?> Цена: <?=$val['price']?> Авиакомпания: <?=$name?> Номер рейса: <?=$val['flight_number']?></div>
.....
<?php } ?>
{"success":true,"data":{"AAQ":{"origin":"REN","destination":"AAQ","price":15450,"transfers":1,"airline":"SU","flight_number":5831,"departure_at":"2016-03-17T19:30:00Z","return_at":"2016-03-28T11:30:00Z","expires_at":"2016-02-09T09:28:27Z"},"AER":{"origin":"REN","destination":"AER","price":15450,"transfers":1,"airline":"SU","flight_number":5833,"departure_at":"2016-03-20T09:00:00Z","return_at":"2016-03-23T06:50:00Z","expires_at":"2016-02-09T09:18:50Z"},"DYU":{"origin":"REN","destination":"DYU","price":25927,"transfers":0,"airline":"SZ","flight_number":212,"departure_at":"2016-02-10T14:10:00Z","return_at":"2016-02-24T09:30:00Z","expires_at":"2016-02-06T16:54:52Z"},"KRR":{"origin":"REN","destination":"KRR","price":15450,"transfers":1,"airline":"SU","flight_number":5831,"departure_at":"2016-03-10T19:30:00Z","return_at":"2016-04-17T10:25:00Z","expires_at":"2016-02-09T04:09:34Z"},"LBD":{"origin":"REN","destination":"LBD","price":31345,"transfers":2,"airline":"U6","flight_number":2625,"departure_at":"2016-07-12T17:00:00Z","return_at":"2016-07-13T21:40:00Z","expires_at":"2016-02-06T18:21:49Z"},"LED":{"origin":"REN","destination":"LED","price":9599,"transfers":1,"airline":"SU","flight_number":1245,"departure_at":"2016-02-27T05:55:00Z","return_at":"2016-04-24T06:25:00Z","expires_at":"2016-02-07T18:45:53Z"},"MOW":{"origin":"REN","destination":"MOW","price":8250,"transfers":0,"airline":"FV","flight_number":6754,"departure_at":"2016-06-09T07:40:00Z","return_at":"2016-06-09T18:45:00Z","expires_at":"2016-02-06T19:17:10Z"},"NUX":{"origin":"REN","destination":"NUX","price":20000,"transfers":1,"airline":"SU","flight_number":1249,"departure_at":"2016-03-14T21:00:00Z","return_at":"2016-04-15T16:05:00Z","expires_at":"2016-02-07T03:38:33Z"},"SIP":{"origin":"REN","destination":"SIP","price":15450,"transfers":1,"airline":"SU","flight_number":5833,"departure_at":"2016-02-12T09:00:00Z","return_at":"2016-02-16T15:15:00Z","expires_at":"2016-02-07T09:08:39Z"},"SVX":{"origin":"REN","destination":"SVX","price":18600,"transfers":2,"airline":"R2","flight_number":5833,"departure_at":"2016-03-17T09:00:00Z","return_at":"2016-03-18T06:15:00Z","expires_at":"2016-02-07T06:01:23Z"}},"error":null,"currency":"rub"}
foreach ($mapping as $item) {
if ($item->iata == $code) {
$name = $item->name;
$departure = $item->departure_at;
break;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question