Answer the question
In order to leave comments, you need to log in
API - JSON - PHP How to set the path to the image?
There is a code
<?php
ini_set('display_errors','On');
error_reporting('E_ALL');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.travelpayouts.com/v1/prices/calendar?currency=RUB&origin=MOW&destination=AER&calendar_type=departure_date");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Access-Token: "));
$response = curl_exec($ch);
curl_close($ch);
//var_dump($response);
$obj = json_decode($response);
echo '<table class="table table-hover">';
echo '<thead>';
echo '<tr>';
echo '<th>Дата вылета</th>';
echo '<th>Стоимость</th>';
echo '<th>Авиакомпания</th>';
echo '<th>Актуально до</th>';
echo '<th>Дата возвращения</th>';
echo '<th>Номер рейса</th>';
echo '<tr> ';
$price = 0;
$num = 0;
$airline = array();
foreach ($obj->data as $key => $item) {
$num++;
$price += $item->price;
if(isset($airline[$item->airline])){
$airline[$item->airline]++;
}else{
$airline[$item->airline] = 1;
}
;
echo '<tr>';
echo '<td>' . date("d.m.Y", strtotime("$item->departure_at")) . '</td>';
echo '<td>' . $item->price . '</td>';
echo '<td>' . $item->airline . '</td>';
echo '<td>' . date("d.m.Y", strtotime("$item->expires_at")) . '</td>';
echo '<td>' . date("d.m.Y", strtotime("$item->return_at")) . '</td>';
echo '<td>' . $item->flight_number . '</td>';
} echo '</tr> '; echo '</table>';
?>
echo '<td>' . $item->airline . '</td>';
I need the airline logo to be displayed
in the code instead of the text part of this code with the pathpics.avs.io/100/40/***.pngwhere instead of asterisks there would be a value
$item->airlineAnd it is also necessary that at the end of each line of the table there is a link called "Search", leading to
bilety.avia-avia.ru/searches/new?origin_iata=MOW&d...where instead of asterisks values from the table would be inserted. Thanks in advance best regards.
Answer the question
In order to leave comments, you need to log in
one.
2.
you know which values from the table should be inserted instead of ***
, let's say $item->departure_at is clear, and the other two are not clear
3. quotes are unnecessary here
strtotime("$item->departure_at")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question