PHP对象操作

时间:2013-12-29 11:02:23

标签: php object multidimensional-array array-key

嗨朋友们。下面是stdClass。我正在尝试解析响应,但它无法正常工作。 我试图使用$od[0]->FlightSegment->ArrivalAirportCode访问该对象似乎无法正常工作。

stdClass Object
(
    [FlightSegment] => Array
        (
            [0] => stdClass Object
                (
                    [AirEquipType] => stdClass Object
                        (
                        )

                    [ArrivalAirportCode] => BOM
                    [ArrivalDateTime] => 2014-01-03T07:15:00
                    [DepartureAirportCode] => BLR
                    [DepartureDateTime] => 2014-01-03T05:45:00
                    [FlightNumber] => 322
                    [OperatingAirlineCode] => G8
                    [OperatingAirlineFlightNumber] => 322
                    [RPH] => stdClass Object
                        (
                        )

                    [StopQuantity] => 0
                    [airLineName] => GoAir
                    [airportTax] => 5136
                    [imageFileName] => http://live.arzoo.com/FlightWS/image/goair.gif
                    [viaFlight] => stdClass Object
                        (
                        )

                    [BookingClass] => stdClass Object
                        (
                            [Availability] => 1
                            [ResBookDesigCode] => R
                        )

                    [BookingClassFare] => stdClass Object
                        (
                            [adultFare] => 6100
                            [bookingclass] => R
                            [classType] => Economy
                            [farebasiscode] => x21RoTBkeV+cJeZY1rthLBbbjLwRoy6/oicf965tvXvjBVjANsWaFZWj53ainYSrB6LTu/WMZsBq
yV/P+wwX0/qcF2MJv3QC
                            [Rule] => This fare is Refundable |Booking Class : R|Cancellation Penalty:INR 1500/- per person per sector.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 250 per passenger w.e.f 16th December 2013.|All fees are subject to change without notice.
                            [adultCommission] => 0
                            [childCommission] => 0
                            [commissionOnTCharge] => 0
                        )

                    [Discount] => 439
                    [airportTaxChild] => 0
                    [airportTaxInfant] => 0
                    [adultTaxBreakup] => 3650,225,1261
                    [childTaxBreakup] => 0,0,0
                    [infantTaxBreakup] => 0,0,0
                    [octax] => 10
                )

            [1] => stdClass Object
                (
                    [AirEquipType] => stdClass Object
                        (
                        )

                    [ArrivalAirportCode] => DEL
                    [ArrivalDateTime] => 2014-01-03T09:45:00
                    [DepartureAirportCode] => BOM
                    [DepartureDateTime] => 2014-01-03T07:35:00
                    [FlightNumber] => 327
                    [OperatingAirlineCode] => G8
                    [OperatingAirlineFlightNumber] => 327
                    [RPH] => stdClass Object
                        (
                        )

                    [StopQuantity] => 0
                    [airLineName] => GoAir
                    [airportTax] => 0
                    [imageFileName] => http://live.arzoo.com/FlightWS/image/goair.gif
                    [viaFlight] => stdClass Object
                        (
                        )

                    [BookingClass] => stdClass Object
                        (
                            [Availability] => 1
                            [ResBookDesigCode] => R
                        )

                    [BookingClassFare] => stdClass Object
                        (
                            [adultFare] => 1
                            [bookingclass] => R
                            [classType] => Economy
                            [farebasiscode] => x21RoTBkeV+cJeZY1rthLBbbjLwRoy6/oicf965tvXvjBVjANsWaFZWj53ainYSrRuiQx8hec5ML
Wf6yMF787w==
                            [Rule] => This fare is Refundable |Booking Class : R|Cancellation Penalty:INR 1500/- per person per sector.|Date Change Penalty: In addition to the airlines date change penalty, we charge a service fee of Rs. 250 per passenger w.e.f 16th December 2013.|All fees are subject to change without notice.
                            [adultCommission] => 0
                            [childCommission] => 0
                            [commissionOnTCharge] => 0
                        )

                    [Discount] => 0
                    [airportTaxChild] => 0
                    [airportTaxInfant] => 0
                    [adultTaxBreakup] => 0,0,0
                    [childTaxBreakup] => 0,0,0
                    [infantTaxBreakup] => 0,0,0
                    [octax] => 10
                )

        )

)

我会放松心情。

任何人都可以告诉我发生了什么事吗?

1 个答案:

答案 0 :(得分:4)

您需要使用$od->FlightSegment[0]->ArrivalAirportCode