-1
我正在使用航空公司航班搜索,並在回顯print_r($ result)時獲得以下輸出。循環瀏覽json和使用php回顯
Unirest\HttpResponse Object
(
[code:Unirest\HttpResponse:private] => 200
[raw_body:Unirest\HttpResponse:private] => {"airTicketListResponse":{"customerSessionId":"1373316267","currency":"USD","routings":[{"key":"Xt4yT/xiADHlJY1rDoGfIW1oqil8CPCWFIlJLLRPgb8^vJwIcDs7qiScjgw^YEk5DvQVRZ1Ge1ut9cq4GDemu8aQQ1r4LqOr3z3asbm/3xcR9G4YzjkKns6CoqNxFEuO8rCrifO9GnKWSQaFrOWE/JRLlKewmNAAGIz41wbgI4BYVBeiWfbPO7v/EDI3y92fKShWVCKarRbMUq4KZ6p^i7ROySEM1S9Kw6pu7OXYgn9NUpIWd1ReV0X^32AROvy^uVtRFCYMKkplFEEEafGVivdQXwii7Be/6Hpmj71D4QKNZsoPzHqH9cehD6123fqhmCkVzSTED3z^B79K/o^3ezOaf73EgLLg8eVB7pqTTk0=","mainAirlineCode":"DL","mainAirlineName":"Delta Airlines","totalPrice":"231.80","adultBasePrice":"196.04","adultTax":"35.76","childBasePrice":"0","childTax":"0","lastTicketDate":"08/05/2013","domesticTicket":true,"duration":"180","tripTime":"180","layover":false,"operatedBy":false,"overnightFlight":false,"overnightStay":false,"publishFare":true,"trips":[{"segments":[{"airlineCode":"DL","airlineName":"Delta Airlines","departureAirportCode":"PHX","departureAirportName":"Sky Harbor International Airport","departureTime":"11/22/2013 06:00","arrivalAirportCode":"LAX","arrivalAirportName":"Los Angeles International Airport","arrivalTime":"11/22/2013 06:35","stop":0,"duration":95,"codeShare":"","cabin":"E","aircraftCode":"Canadair RJ","flightNumber":"4578","departureCity":"Phoenix","departureStateCode":"AZ","departureCountryCode":"US","departureCountryName":"United States","arrivalCity":"Los Angeles","arrivalStateCode":"CA","arrivalCountryCode":"US","arrivalCountryName":"United States","BookingClass":"T","MarriageGroup":"O"}],"duration":"95","tripTime":"95"},{"segments":[{"airlineCode":"DL","airlineName":"Delta Airlines","departureAirportCode":"LAX","departureAirportName":"Los Angeles International Airport","departureTime":"12/22/2013 08:30","arrivalAirportCode":"PHX","arrivalAirportName":"Sky Harbor International Airport","arrivalTime":"12/22/2013 10:55","stop":0,"duration":85,"codeShare":"","cabin":"E","aircraftCode":"Canadair RJ","flightNumber":"4793","departureCity":"Los Angeles","departureStateCode":"CA","departureCountryCode":"US","departureCountryName":"United States","arrivalCity":"Phoenix","arrivalStateCode":"AZ","arrivalCountryCode":"US","arrivalCountryName":"United States","BookingClass":"X","MarriageGroup":"O"}],"duration":"85","tripTime":"85"}]},
如何循環瀏覽並返回mainAirlineName和adultBasePrice以返回每個項目?我不知道這是一個數組內的數組,或者我可能通過print_r($ result)搞砸了一些東西。
帕特里克感謝你的幫助。我已經對我的$結果進行了編輯。我很抱歉,但我想我可能已經發布了$結果錯誤。你能看看嗎?我已經嘗試了你的答案,但它不起作用,但可能是因爲我提供了錯誤的$結果。 – DSmith
@帕特里克...仍然沒有得到它...我錯過了什麼? – DSmith
明白了!感謝帕特里克的幫助! – DSmith