0

只想输出我使用的数组:https ://github.com/dahabtours/amadeus-php-sdk

$date_checkin = '2019-07-16';
$date_checkout = '2019-07-18';

require('AmadeusClient.php');

$amadeus_api = new AmadeusDahabtours\SelfServiceApiClient('CLIENT_ID','CLIENT_SECRET');

# Flight Low-fare Search
$flight_offers = $amadeus_api->lowFares([
    'origin'          => 'AMS',
    'destination'     => 'BCN',
    'departureDate'   => $date_checkin,
    'returnDate'      => $date_checkout,
    'nonStop'         => true,
    'currency'        => 'EUR',
    'max'             => 2,
]);

我希望输出是这样的:

<div class="flights">
   <div class="flight-1">VALUES</div>
   <div class="flight-2">VALUES</div>
   <div class="flight-3">VALUES</div>
</div>

大批:

array(5) {
  ["success"]=>
  bool(true)
  ["msgs"]=>
  array(0) {
  }
  ["http_code"]=>
  int(200)
  ["response_text"]=>
  string(2597) "{"data":[{"type":"flight-offer","id":"1562680375384--1832628087","offerItems":[{"services":[{"segments":[{"flightSegment":{"departure":{"iataCode":"AMS","terminal":"3","at":"2019-07-16T07:00:00+02:00"},"arrival":{"iataCode":"BCN","terminal":"1","at":"2019-07-16T09:20:00+02:00"},"carrierCode":"IB","number":"5224","aircraft":{"code":"320"},"operating":{"carrierCode":"VY","number":"5224"},"duration":"0DT2H20M"},"pricingDetailPerAdult":{"travelClass":"ECONOMY","fareClass":"V","availability":4,"fareBasis":"VRTNVY"}}]},{"segments":[{"flightSegment":{"departure":{"iataCode":"BCN","terminal":"1","at":"2019-07-18T12:05:00+02:00"},"arrival":{"iataCode":"AMS","at":"2019-07-18T14:30:00+02:00"},"carrierCode":"IB","number":"5685","aircraft":{"code":"320"},"operating":{"carrierCode":"VY","number":"5685"},"duration":"0DT2H25M"},"pricingDetailPerAdult":{"travelClass":"ECONOMY","fareClass":"A","availability":4,"fareBasis":"ARTNVY"}}]}],"price":{"total":"209.09","totalTaxes":"74.09"},"pricePerAdult":{"total":"209.09","totalTaxes":"74.09"}}]},{"type":"flight-offer","id":"1562680375384--510820791","offerItems":[{"services":[{"segments":[{"flightSegment":{"departure":{"iataCode":"AMS","at":"2019-07-16T07:00:00+02:00"},"arrival":{"iataCode":"BCN","terminal":"1","at":"2019-07-16T09:20:00+02:00"},"carrierCode":"VY","number":"8318","aircraft":{"code":"320"},"operating":{"carrierCode":"VY","number":"8318"},"duration":"0DT2H20M"},"pricingDetailPerAdult":{"travelClass":"ECONOMY","fareClass":"X","availability":6,"fareBasis":"XRTVY"}}]},{"segments":[{"flightSegment":{"departure":{"iataCode":"BCN","terminal":"1","at":"2019-07-18T12:05:00+02:00"},"arrival":{"iataCode":"AMS","at":"2019-07-18T14:30:00+02:00"},"carrierCode":"VY","number":"8302","aircraft":{"code":"321"},"operating":{"carrierCode":"VY","number":"8302"},"duration":"0DT2H25M"},"pricingDetailPerAdult":{"travelClass":"ECONOMY","fareClass":"P","availability":8,"fareBasis":"PRTVY"}}]}],"price":{"total":"209.09","totalTaxes":"74.09"},"pricePerAdult":{"total":"209.09","totalTaxes":"74.09"}}]}],"dictionaries":{"carriers":{"VY":"VUELING AIRLINES","IB":"IBERIA"},"currencies":{"EUR":"EURO"},"aircraft":{"320":"AIRBUS INDUSTRIE A320-100/200","321":"AIRBUS INDUSTRIE A321"},"locations":{"AMS":{"subType":"AIRPORT","detailedName":"SCHIPHOL AIRPORT"},"BCN":{"subType":"AIRPORT","detailedName":"AIRPORT"}}},"meta":{"links":{"self":"https://test.api.amadeus.com/v1/shopping/flight-offers?origin=AMS&destination=BCN&departureDate=2019-07-16&returnDate=2019-07-18&adults=1&nonStop=true¤cy=EUR&max=2"},"currency":"EUR","defaults":{"adults":1}}}"
  ["response"]=>
  array(3) {
    ["data"]=>
    array(2) {
      [0]=>
      array(3) {
        ["type"]=>
        string(12) "flight-offer"
        ["id"]=>
        string(25) "1562680375384--1832628087"
        ["offerItems"]=>
        array(1) {
          [0]=>
          array(3) {
            ["services"]=>
            array(2) {
              [0]=>
              array(1) {
                ["segments"]=>
                array(1) {
                  [0]=>
                  array(2) {
                    ["flightSegment"]=>
                    array(7) {
                      ["departure"]=>
                      array(3) {
                        ["iataCode"]=>
                        string(3) "AMS"
                        ["terminal"]=>
                        string(1) "3"
                        ["at"]=>
                        string(25) "2019-07-16T07:00:00+02:00"
                      }
                      ["arrival"]=>
                      array(3) {
                        ["iataCode"]=>
                        string(3) "BCN"
                        ["terminal"]=>
                        string(1) "1"
                        ["at"]=>
                        string(25) "2019-07-16T09:20:00+02:00"
                      }
                      ["carrierCode"]=>
                      string(2) "IB"
                      ["number"]=>
                      string(4) "5224"
                      ["aircraft"]=>
                      array(1) {
                        ["code"]=>
                        string(3) "320"
                      }
                      ["operating"]=>
                      array(2) {
                        ["carrierCode"]=>
                        string(2) "VY"
                        ["number"]=>
                        string(4) "5224"
                      }
                      ["duration"]=>
                      string(8) "0DT2H20M"
                    }
                    ["pricingDetailPerAdult"]=>
                    array(4) {
                      ["travelClass"]=>
                      string(7) "ECONOMY"
                      ["fareClass"]=>
                      string(1) "V"
                      ["availability"]=>
                      int(4)
                      ["fareBasis"]=>
                      string(6) "VRTNVY"
                    }
                  }
                }
              }
              [1]=>
              array(1) {
                ["segments"]=>
                array(1) {
                  [0]=>
                  array(2) {
                    ["flightSegment"]=>
                    array(7) {
                      ["departure"]=>
                      array(3) {
                        ["iataCode"]=>
                        string(3) "BCN"
                        ["terminal"]=>
                        string(1) "1"
                        ["at"]=>
                        string(25) "2019-07-18T12:05:00+02:00"
                      }
                      ["arrival"]=>
                      array(2) {
                        ["iataCode"]=>
                        string(3) "AMS"
                        ["at"]=>
                        string(25) "2019-07-18T14:30:00+02:00"
                      }
                      ["carrierCode"]=>
                      string(2) "IB"
                      ["number"]=>
                      string(4) "5685"
                      ["aircraft"]=>
                      array(1) {
                        ["code"]=>
                        string(3) "320"
                      }
                      ["operating"]=>
                      array(2) {
                        ["carrierCode"]=>
                        string(2) "VY"
                        ["number"]=>
                        string(4) "5685"
                      }
                      ["duration"]=>
                      string(8) "0DT2H25M"
                    }
                    ["pricingDetailPerAdult"]=>
                    array(4) {
                      ["travelClass"]=>
                      string(7) "ECONOMY"
                      ["fareClass"]=>
                      string(1) "A"
                      ["availability"]=>
                      int(4)
                      ["fareBasis"]=>
                      string(6) "ARTNVY"
                    }
                  }
                }
              }
            }
            ["price"]=>
            array(2) {
              ["total"]=>
              string(6) "209.09"
              ["totalTaxes"]=>
              string(5) "74.09"
            }
            ["pricePerAdult"]=>
            array(2) {
              ["total"]=>
              string(6) "209.09"
              ["totalTaxes"]=>
              string(5) "74.09"
            }
          }
        }
      }
      [1]=>
      array(3) {
        ["type"]=>
        string(12) "flight-offer"
        ["id"]=>
        string(24) "1562680375384--510820791"
        ["offerItems"]=>
        array(1) {
          [0]=>
          array(3) {
            ["services"]=>
            array(2) {
              [0]=>
              array(1) {
                ["segments"]=>
                array(1) {
                  [0]=>
                  array(2) {
                    ["flightSegment"]=>
                    array(7) {
                      ["departure"]=>
                      array(2) {
                        ["iataCode"]=>
                        string(3) "AMS"
                        ["at"]=>
                        string(25) "2019-07-16T07:00:00+02:00"
                      }
                      ["arrival"]=>
                      array(3) {
                        ["iataCode"]=>
                        string(3) "BCN"
                        ["terminal"]=>
                        string(1) "1"
                        ["at"]=>
                        string(25) "2019-07-16T09:20:00+02:00"
                      }
                      ["carrierCode"]=>
                      string(2) "VY"
                      ["number"]=>
                      string(4) "8318"
                      ["aircraft"]=>
                      array(1) {
                        ["code"]=>
                        string(3) "320"
                      }
                      ["operating"]=>
                      array(2) {
                        ["carrierCode"]=>
                        string(2) "VY"
                        ["number"]=>
                        string(4) "8318"
                      }
                      ["duration"]=>
                      string(8) "0DT2H20M"
                    }
                    ["pricingDetailPerAdult"]=>
                    array(4) {
                      ["travelClass"]=>
                      string(7) "ECONOMY"
                      ["fareClass"]=>
                      string(1) "X"
                      ["availability"]=>
                      int(6)
                      ["fareBasis"]=>
                      string(5) "XRTVY"
                    }
                  }
                }
              }
              [1]=>
              array(1) {
                ["segments"]=>
                array(1) {
                  [0]=>
                  array(2) {
                    ["flightSegment"]=>
                    array(7) {
                      ["departure"]=>
                      array(3) {
                        ["iataCode"]=>
                        string(3) "BCN"
                        ["terminal"]=>
                        string(1) "1"
                        ["at"]=>
                        string(25) "2019-07-18T12:05:00+02:00"
                      }
                      ["arrival"]=>
                      array(2) {
                        ["iataCode"]=>
                        string(3) "AMS"
                        ["at"]=>
                        string(25) "2019-07-18T14:30:00+02:00"
                      }
                      ["carrierCode"]=>
                      string(2) "VY"
                      ["number"]=>
                      string(4) "8302"
                      ["aircraft"]=>
                      array(1) {
                        ["code"]=>
                        string(3) "321"
                      }
                      ["operating"]=>
                      array(2) {
                        ["carrierCode"]=>
                        string(2) "VY"
                        ["number"]=>
                        string(4) "8302"
                      }
                      ["duration"]=>
                      string(8) "0DT2H25M"
                    }
                    ["pricingDetailPerAdult"]=>
                    array(4) {
                      ["travelClass"]=>
                      string(7) "ECONOMY"
                      ["fareClass"]=>
                      string(1) "P"
                      ["availability"]=>
                      int(8)
                      ["fareBasis"]=>
                      string(5) "PRTVY"
                    }
                  }
                }
              }
            }
            ["price"]=>
            array(2) {
              ["total"]=>
              string(6) "209.09"
              ["totalTaxes"]=>
              string(5) "74.09"
            }
            ["pricePerAdult"]=>
            array(2) {
              ["total"]=>
              string(6) "209.09"
              ["totalTaxes"]=>
              string(5) "74.09"
            }
          }
        }
      }
    }
    ["dictionaries"]=>
    array(4) {
      ["carriers"]=>
      array(2) {
        ["VY"]=>
        string(16) "VUELING AIRLINES"
        ["IB"]=>
        string(6) "IBERIA"
      }
      ["currencies"]=>
      array(1) {
        ["EUR"]=>
        string(4) "EURO"
      }
      ["aircraft"]=>
      array(2) {
        [320]=>
        string(29) "AIRBUS INDUSTRIE A320-100/200"
        [321]=>
        string(21) "AIRBUS INDUSTRIE A321"
      }
      ["locations"]=>
      array(2) {
        ["AMS"]=>
        array(2) {
          ["subType"]=>
          string(7) "AIRPORT"
          ["detailedName"]=>
          string(16) "SCHIPHOL AIRPORT"
        }
        ["BCN"]=>
        array(2) {
          ["subType"]=>
          string(7) "AIRPORT"
          ["detailedName"]=>
          string(7) "AIRPORT"
        }
      }
    }
    ["meta"]=>
    array(3) {
      ["links"]=>
      array(1) {
        ["self"]=>
        string(169) "https://test.api.amadeus.com/v1/shopping/flight-offers?origin=AMS&destination=BCN&departureDate=2019-07-16&returnDate=2019-07-18&adults=1&nonStop=true¤cy=EUR&max=2"
      }
      ["currency"]=>
      string(3) "EUR"
      ["defaults"]=>
      array(1) {
        ["adults"]=>
        int(1)
      }
    }
  }
}
4

1 回答 1

0

现在我有这个:

foreach ( $flight_offers as $flights ) {
    if (is_array( $flights ) ){
        foreach ( $flights as $value ) {
            echo $value;
        }
    } else {
        echo $flights;
    }
}
于 2019-07-09T14:54:20.057 回答