[英]Retrieve values of multidimentional array in PHP
我無法從此多維數組檢索所有數據。 我已經使用foreach循環進行了編碼,但是由於內部循環無法正常工作,因此顯示錯誤。請幫助我。
這是我嘗試過的代碼
foreach($capture as $k) {
foreach($k['ReportLines'] as $detail){
echo $detail['Quantity'];
echo $k['Description'];
}
}
這是數組
$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
)
)
)
嘗試這種方式:
foreach($capture['ReportLines'] as $detail) {
echo $detail['Quantity'];
echo $detail['Description'];
}
對不起,我的回復很快,但我是從電話寫的。
我會盡快編輯答案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.