如何使用php获取foreach循环中的多维数组值[关闭]

This my code ..... I need output of hotel name, id, selling price etc array value will be loop because I have get result in bulk manner .

Array
(
    [TestMode] => true
    [HotelAvailability] => Array
        (
            [0] => Array
                (
                    [Hotel] => Array
                        (
                            [Id] => 3027405
                            [Name] => Royal Plaza
                            [Region] => Array
                                (
                                    [Id] => 16849
                                    [Name] => Chennai (Madras)
                                )

                            [Type] => Hotel
                            [Stars] => 3
                            [Rank] => 1
                        )

                    [Result] => Array
                        (
                            [QuoteId] => 12249136-10
                            [Room] => Array
                                (
                                    [RoomType] => Array
                                        (
                                            [Code] => 1002196
                                            [Text] => Double Standard
                                        )

                                    [MealType] => Array
                                        (
                                            [Code] => 1000018
                                            [Text] => Bed and breakfast
                                        )

                                    [SellingPrice] => Array
                                        (
                                            [Currency] => INR
                                            [Amount] => 1824.26
                                            [Estimated] => false
                                            [Converted] => false
                                        )

                                    [Guests] => Array
                                        (
                                            [Adult] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [Id] => -252645204
                                                            [Forename] => Array
                                                                (
                                                                )

                                                            [Surname] => Array
                                                                (
                                                                )

                                                            [SellingPrice] => Array
                                                                (
                                                                    [Currency] => INR
                                                                    [Amount] => 912.13
                                                                    [Estimated] => false
                                                                    [Converted] => false
                                                                )

                                                        )

                                                    [1] => Array
                                                        (
                                                            [Id] => -252645205
                                                            [Forename] => Array
                                                                (
                                                                )

                                                            [Surname] => Array
                                                                (
                                                                )

                                                            [SellingPrice] => Array
                                                                (
                                                                    [Currency] => INR
                                                                    [Amount] => 912.13
                                                                    [Estimated] => false
                                                                    [Converted] => false
                                                                )

                                                        )

                                                )

                                        )

                                    [Confirmation] => allocation
                                )

                        )

                )

            [1] => Array
                (
                    [Hotel] => Array
                        (
                            [Id] => 2118726
                            [Name] => Days Inn Deccan Plaza
                            [Region] => Array
                                (
                                    [Id] => 16849
                                    [Name] => Chennai (Madras)
                                )

                            [Type] => Hotel
                            [Stars] => 3
                            [Rank] => 1
                        )

                    [Result] => Array
                        (
                            [QuoteId] => 12249136-36
                            [Room] => Array
                                (
                                    [RoomType] => Array
                                        (
                                            [Code] => 1002196
                                            [Text] => Double Standard
                                        )

                                    [MealType] => Array
                                        (
                                            [Code] => 1000018
                                            [Text] => Bed and breakfast
                                        )

                                    [SellingPrice] => Array
                                        (
                                            [Currency] => INR
                                            [Amount] => 3192.90
                                            [Estimated] => false
                                            [Converted] => false
                                        )

                                    [Guests] => Array
                                        (
                                            [Adult] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [Id] => -252645292
                                                            [Forename] => Array
                                                                (
                                                                )

                                                            [Surname] => Array
                                                                (
                                                                )

                                                            [SellingPrice] => Array
                                                                (
                                                                    [Currency] => INR
                                                                    [Amount] => 1596.45
                                                                    [Estimated] => false
                                                                    [Converted] => false
                                                                )

                                                        )

                                                    [1] => Array
                                                        (
                                                            [Id] => -252645293
                                                            [Forename] => Array
                                                                (
                                                                )

                                                            [Surname] => Array
                                                                (
                                                                )

                                                            [SellingPrice] => Array
                                                                (
                                                                    [Currency] => INR
                                                                    [Amount] => 1596.45
                                                                    [Estimated] => false
                                                                    [Converted] => false
                                                                )

                                                        )

                                                )

                                        )

                                    [Confirmation] => allocation
                                )

                        )

                )

            [2] => Array
                (
                    [Hotel] => Array
                        (
                            [Id] => 723729
                            [Name] => Green Park
                            [Region] => Array
                                (
                                    [Id] => 16849
                                    [Name] => Chennai (Madras)
                                )

                            [Type] => Hotel
                            [Stars] => 4
                            [Rank] => 1
                        )

                    [Result] => Array
                        (
                            [0] => Array
                                (
                                    [QuoteId] => 12249136-33
                                    [Room] => Array
                                        (
                                            [RoomType] => Array
                                                (
                                                    [Code] => 1004527
                                                    [Text] => Double Or Twin Deluxe
                                                )

                                            [MealType] => Array
                                                (
                                                    [Code] => 1000018
                                                    [Text] => Bed and breakfast
                                                )

                                            [SellingPrice] => Array
                                                (
                                                    [Currency] => INR
                                                    [Amount] => 3273.82
                                                    [Estimated] => false
                                                    [Converted] => false
                                                )

                                            [Guests] => Array
                                                (
                                                    [Adult] => Array
                                                        (
                                                            [0] => Array
                                                                (
                                                                    [Id] => -252645286
                                                                    [Forename] => Array
                                                                        (
                                                                        )

                                                                    [Surname] => Array
                                                                        (
                                                                        )

                                                                    [SellingPrice] => Array
                                                                        (
                                                                            [Currency] => INR
                                                                            [Amount] => 1636.91
                                                                            [Estimated] => false
                                                                            [Converted] => false
                                                                        )

                                                                )

                                                            [1] => Array
                                                                (
                                                                    [Id] => -252645287
                                                                    [Forename] => Array
                                                                        (
                                                                        )

                                                                    [Surname] => Array
                                                                        (
                                                                        )

                                                                    [SellingPrice] => Array
                                                                        (
                                                                            [Currency] => INR
                                                                            [Amount] => 1636.91
                                                                            [Estimated] => false
                                                                            [Converted] => false
                                                                        )

                                                                )

                                                        )

                                                )

                                            [Confirmation] => allocation
                                        )

                                )

                            [1] => Array
                                (
                                    [QuoteId] => 12249136-34
                                    [Room] => Array
                                        (
                                            [RoomType] => Array
                                                (
                                                    [Code] => 2062742
                                                    [Text] => Double or Twin BUSINESS-CLUB
                                                )

                                            [MealType] => Array
                                                (
                                                    [Code] => 1000018
                                                    [Text] => Bed and breakfast
                                                )

                                            [SellingPrice] => Array
                                                (
                                                    [Currency] => INR
                                                    [Amount] => 3863.18
                                                    [Estimated] => false
                                                    [Converted] => false
                                                )

                                            [Guests] => Array
                                                (
                                                    [Adult] => Array
                                                        (
                                                            [0] => Array
                                                                (
                                                                    [Id] => -252645288
                                                                    [Forename] => Array
                                                                        (
                                                                        )

                                                                    [Surname] => Array
                                                                        (
                                                                        )

                                                                    [SellingPrice] => Array
                                                                        (
                                                                            [Currency] => INR
                                                                            [Amount] => 1931.59
                                                                            [Estimated] => false
                                                                            [Converted] => false
                                                                        )

                                                                )

                                                            [1] => Array
                                                                (
                                                                    [Id] => -252645289
                                                                    [Forename] => Array
                                                                        (
                                                                        )

                                                                    [Surname] => Array
                                                                        (
                                                                        )

                                                                    [SellingPrice] => Array
                                                                        (
                                                                            [Currency] => INR
                                                                            [Amount] => 1931.59
                                                                            [Estimated] => false
                                                                            [Converted] => false
                                                                        )

                                                                )

                                                        )

                                                )

                                            [Confirmation] => allocation
                                        )

                                )

                        )

                )
foreach($data['HotelAvailability'] AS $record) {
     echo 'Id: '; echo $record['Hotel']['Id'];
     echo '<br />';
     echo 'Name: '; echo $record['Hotel']['Name'];
     echo '-------------'; echo '<br />';
}

If I understood your question correctly, you would like to extract the Hotel Id, Name, and SellingPrice keys from this array, in a loop.

If we assume the above array is stored in a variable called $HotelData, and that the array structure is consistent with the above output in your question, then the following code should allow you to do what you want...

foreach($HotelData['HotelAvailability'] as $hotel) {
    $id = $hotel['Hotel']['Id'];
    $name = $hotel['Hotel']['Name'];
    $price = $hotel['Result']['Room']['SellingPrice']['Currency'] . ' ' . $hotel['Result']['Room']['SellingPrice']['Amount'] ;

    echo "$id - $name: $price<br>
";
}

/* This should output something like
*  
*  3027405 - Royal Plaza: INR 1824.26
*  2118726 - Days Inn Deccan Plaza - INR 3192.90
*  ...
*/