简体   繁体   English

在PHP中检索多维数组的值

[英]Retrieve values of multidimentional array in PHP

Im not able to retrieve all the data from this multidimensional array. 我无法从此多维数组检索所有数据。 I have coded using foreach loop but it shows error as the inner loop isnt working out fine.. Please help me. 我已经使用foreach循环进行了编码,但是由于内部循环无法正常工作,因此显示错误。请帮助我。

This is the code I have tried 这是我尝试过的代码

 foreach($capture as $k) {
    foreach($k['ReportLines'] as $detail){

         echo $detail['Quantity'];
         echo $k['Description'];
   }
   }

This is the array 这是数组

  $capture=  Array
(

[ReportLines] => 
    Array([0] => 
        Array(

            [Quantity] => 4.00

                    [Item] => MISPM
                            [Description] => Midnight
                            [Price] => 30.00
                            [Amount] => 120.00
                         )

                  [1] => 
        Array(

            [Quantity] => 40.00

                    [Item] => BMISPM
                            [Description] => Midnight2
                            [Price] => 340.00
                            [Amount] => 1220.00
                         )
                  [2] => 
        Array(

            [Quantity] => 24.00

                    [Item] => AMISPM
                            [Description] => Midnight3
                            [Price] => 3250.00
                            [Amount] => 1220.00
                         )
                  ([3] => 
        Array(

            [Quantity] => 34.00

                    [Item] => MIeSPM
                            [Description] => Midnight
                            [Price] => 30.00
                            [Amount] => 120.00
                         )
    )

)

Try this way: 尝试这种方式:

foreach($capture['ReportLines'] as $detail) { 
    echo $detail['Quantity'];
    echo $detail['Description'];
}

Sorry for fast response but i'm writing from phone. 对不起,我的回复很快,但我是从电话写的。

I will edit the answer as soon as possible 我会尽快编辑答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM