Hello How To Generate HTML Table from Curl Response ?
<pre><?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.travelpayouts.com/v1/prices/cheap?origin=SAW&destination=AYT&depart_date=2022-10-26&return_date=2022-10-27¤cy=usd", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "x-access-token: xxxxxxxxxxxxxxxxxxxxx" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { $json = json_decode($response, true); print_r($json); } ?> <?php for($i=0;$i<count($data[0]["data"]);$i++) { echo('<tr>'); echo('<td>' . $data[0]['data'][$i]['price'] . '</td>'); echo('<td>' . $data[0]['data'][$i]['airline'] . '</td>'); echo('<td>' . $data[0]['data'][$i]['flight_number'] . '</td>'); echo('</tr>'); }?>
<pre> Array ( [AYT] => Array ( [0] => Array ( [price] => 145 [airline] => PC [flight_number] => 4000 [departure_at] => 2022-10-26T18:10:00+03:00 [return_at] => 2022-10-27T05:55:00+03:00 [expires_at] => 2022-10-26T01:55:58Z ) [1] => Array ( [price] => 389 [airline] => PC [flight_number] => 1910 [departure_at] => 2022-10-26T06:20:00+03:00 [return_at] => 2022-10-27T05:55:00+03:00 [expires_at] => 2022-10-26T01:55:58Z ) [2] => Array ( [price] => 349 [airline] => PC [flight_number] => 2666 [departure_at] => 2022-10-26T11:40:00+03:00 [return_at] => 2022-10-27T05:55:00+03:00 [expires_at] => 2022-10-26T01:55:58Z ) ) )
I want to export curl output to html table, but I'm getting an error. Can you help me?
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)