如何从php.please中的数组中获取所有值帮助我

时间:2015-02-26 20:02:39

标签: php arrays xml json

我想从这个数组中获取所有值,我尝试但是我没有成功,所以请帮助我

Array
(
[OTA_AirLowFareSearchRS] => Array
    (
        [attr] => Array
            (
                [xmlns] => http://webservices.sabre.com/sabreXML/2011/10
                [Version] => 2.3.0
            )

        [stl:ApplicationResults] => Array
            (
                [attr] => Array
                    (
                        [xmlns:stl] => http://services.sabre.com/STL/v01
                        [status] => Complete
                    )

                [stl:Success] => Array
                    (
                        [attr] => Array
                            (
                                [timeStamp] => 2015-02-26T13:41:04.79-06:00
                            )

                    )

                [stl:Warning] => Array
                    (
                        [attr] => Array
                            (
                                [type] => BusinessLogic
                                [timeStamp] => 2015-02-26T13:41:04.79-06:00
                            )

                        [stl:SystemSpecificResults] => Array
                            (
                                [stl:Message] => Array
                                    (
                                        [0] => Array
                                            (
                                                [value] => NO FARE FOR CLASS USED
                                                [attr] => Array
                                                    (
                                                        [code] => MIP:PROCESS
                                                    )

                                            )

                                        [1] => Array
                                            (
                                                [value] => NO COMBINABLE FARES FOR CLASS USED
                                                [attr] => Array
                                                    (
                                                        [code] => MIP:PROCESS
                                                    )

                                            )

                                    )

                                [stl:ShortText] => Array
                                    (
                                        [value] => WARN.SWS.ORCH.PROVIDER_WARNING
                                    )

                            )

                    )

            )

        [PricedItineraries] => Array
            (
                [PricedItinerary] => Array
                    (
                        [0] => Array
                            (
                                [attr] => Array
                                    (
                                        [CurrencyCode] => PKR
                                        [RPH] => 1
                                        [TotalAmount] => 11889
                                    )

                                [AirItineraryPricingInfo] => Array
                                    (
                                        [FareCalculation] => Array
                                            (
                                                [Text] => Array
                                                    (
                                                        [value] => ISB PK KHI5300PKR5300END
                                                    )

                                            )

                                        [ItinTotalFare] => Array
                                            (
                                                [BaseFare] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Amount] => 5300
                                                                [CurrencyCode] => PKR
                                                            )

                                                    )

                                                [Commission] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Amount] => 0
                                                                [Percent] => 0.00
                                                            )

                                                    )

                                                [EquivFare] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Amount] => 5300
                                                                [CurrencyCode] => PKR
                                                            )

                                                    )

                                                [Taxes] => Array
                                                    (
                                                        [Tax] => Array
                                                            (
                                                                [0] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 3000
                                                                                [TaxCode] => YQ
                                                                                [TaxName] => SERVICE FEE - FUEL
                                                                            )

                                                                    )

                                                                [1] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 202
                                                                                [TaxCode] => YQ
                                                                                [TaxName] => SERVICE FEE - INSURANCE
                                                                            )

                                                                    )

                                                                [2] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 300
                                                                                [TaxCode] => SP
                                                                                [TaxName] => EMBARKATION TAX
                                                                            )

                                                                    )

                                                                [3] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 2500
                                                                                [TaxCode] => PK
                                                                                [TaxName] => EXCISE DUTY
                                                                            )

                                                                    )

                                                                [4] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 20
                                                                                [TaxCode] => YI
                                                                                [TaxName] => GOVERNMENT AIRPORT TAX
                                                                            )

                                                                    )

                                                                [5] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 567
                                                                                [TaxCode] => PB
                                                                                [TaxName] => ADVANCE TAX
                                                                            )

                                                                    )

                                                            )

                                                    )

                                                [TotalFare] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Amount] => 11889.00
                                                                [CurrencyCode] => PKR
                                                            )

                                                    )

                                                [Warnings] => Array
                                                    (
                                                        [Warning] => Array
                                                            (
                                                                [0] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [ShortText] => PK ONLY/ NON END
                                                                            )

                                                                    )

                                                                [1] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [ShortText] => VALIDATING CARRIER - PK
                                                                            )

                                                                    )

                                                            )

                                                    )

                                            )

                                        [PassengerTypeQuantity] => Array
                                            (
                                                [attr] => Array
                                                    (
                                                        [Code] => ADT
                                                        [Quantity] => 1
                                                    )

                                            )

                                        [PTC_FareBreakdown] => Array
                                            (
                                                [FareBasis] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Code] => OOW1
                                                                [FarePassengerType] => ADT
                                                                [GlobalInd] => EH
                                                                [Market] => ISBKHI
                                                            )

                                                    )

                                            )

                                    )

                                [HeaderInformation] => Array
                                    (
                                        [ValidInterline] => Array
                                            (
                                                [attr] => Array
                                                    (
                                                        [Ind] => true
                                                    )

                                            )

                                        [ValidatingCarrier] => Array
                                            (
                                                [attr] => Array
                                                    (
                                                        [Code] => PK
                                                    )

                                            )

                                    )

                                [OriginDestinationOption] => Array
                                    (
                                        [attr] => Array
                                            (
                                                [RPH] => 1
                                            )

                                        [FlightSegment] => Array
                                            (
                                                [attr] => Array
                                                    (
                                                        [ArrivalDateTime] => 2015-02-27T23:55
                                                        [DepartureDateTime] => 2015-02-27T22:00
                                                        [DestinationTimeZone] => 5
                                                        [DivideInd] => false
                                                        [ElapsedTime] => 115
                                                        [eTicket] => true
                                                        [FlightNumber] => 319
                                                        [MarketingCabin] => Y
                                                        [OriginTimeZone] => 5
                                                        [StopQuantity] => 0
                                                        [ResBookDesigCode] => O
                                                        [RPH] => 1
                                                    )

                                                [DestinationLocation] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [LocationCode] => KHI
                                                            )

                                                    )

                                                [Equipment] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [AirEquipType] => 738
                                                            )

                                                    )

                                                [MarketingAirline] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Code] => PK
                                                                [FlightNumber] => 319
                                                            )

                                                    )

                                                [MarriageGrp] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Ind] => O
                                                            )

                                                    )

                                                [Meal] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [MealCode] => S
                                                            )

                                                    )

                                                [OperatingAirline] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Code] => PK
                                                            )

                                                    )

                                                [OriginLocation] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [LocationCode] => ISB
                                                            )

                                                    )

                                            )

                                    )

                            )

                        [1] => Array
                            (
                                [attr] => Array
                                    (
                                        [CurrencyCode] => PKR
                                        [RPH] => 2
                                        [TotalAmount] => 13884
                                    )

                                [AirItineraryPricingInfo] => Array
                                    (
                                        [FareCalculation] => Array
                                            (
                                                [Text] => Array
                                                    (
                                                        [value] => ISB PK KHI7200PKR7200END
                                                    )

                                            )

                                        [ItinTotalFare] => Array
                                            (
                                                [BaseFare] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Amount] => 7200
                                                                [CurrencyCode] => PKR
                                                            )

                                                    )

                                                [Commission] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Amount] => 0
                                                                [Percent] => 0.00
                                                            )

                                                    )

                                                [EquivFare] => Array
                                                    (
                                                        [attr] => Array
                                                            (
                                                                [Amount] => 7200
                                                                [CurrencyCode] => PKR
                                                            )

                                                    )

                                                [Taxes] => Array
                                                    (
                                                        [Tax] => Array
                                                            (
                                                                [0] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 3000
                                                                                [TaxCode] => YQ
                                                                                [TaxName] => SERVICE FEE - FUEL
                                                                            )

                                                                    )

                                                                [1] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 202
                                                                                [TaxCode] => YQ
                                                                                [TaxName] => SERVICE FEE - INSURANCE
                                                                            )

                                                                    )

                                                                [2] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 300
                                                                                [TaxCode] => SP
                                                                                [TaxName] => EMBARKATION TAX
                                                                            )

                                                                    )

                                                                [3] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 2500
                                                                                [TaxCode] => PK
                                                                                [TaxName] => EXCISE DUTY
                                                                            )

                                                                    )

                                                                [4] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 20
                                                                                [TaxCode] => YI
                                                                                [TaxName] => GOVERNMENT AIRPORT TAX
                                                                            )

                                                                    )

                                                                [5] => Array
                                                                    (
                                                                        [attr] => Array
                                                                            (
                                                                                [Amount] => 662
                                                                                [TaxCode] => PB
                                                                                [TaxName] => ADVANCE TAX
                                                                            )

                                                                    )

                                                            )

                                                    )

                                                [TotalFare] => Array
                                                    (
                                                        [attr] => Array
                                                            (

http://rehmantravel.com/xml/

1 个答案:

答案 0 :(得分:1)

很难说正是你想要实现的目标(欢迎提供更多详细信息!)但是,要将每个键值对迭代为一组,这里有一个简单的例子array_walk_recursive

array_walk_recursive($testData, function($v, $k) {
    echo $k . " => " . (string)$v . PHP_EOL;
});

还有其他几个array_xyz函数可以很容易地被逼入递归;根据您尝试的操作,不同的功能更有用。