我正试图用一个具有多个级别/键的数组构建一个html表,我不太确定如何在主循环之后正确地映射东西。
$RootData
我得到:
RootData{
+innerData:array:2[
"01"=>array:5[
"name"=>"NAME"
"number"=>01
"totals1"=>array:3[
"sales"=>50
"returns"=>100
"total"=>150
]
"totals2"=>array:3[
"sales"=>50
"returns"=>100
"total"=>150
]
"totals3"=>array:3[
"sales"=>50
"returns"=>100
"total"=>150
]
]
"02"=>array:5[
"name"=>"NAME2"
"number"=>02
"totals1"=>array:3[
"sales"=>500
"returns"=>100
"total"=>650
]
"totals2"=>array:3[
"sales"=>500
"returns"=>100
"total"=>650
]
"totals3"=>array:3[
"sales"=>500
"returns"=>100
"total"=>650
]
]
]
}
使用它,我试图得到一个表结构,比如:
NAME | totals1 | totals2 | totals3
-----------------------------------
sales 50 50 50
returns 100 100 100
total 150 150 150
NAME2 | totals1 | totals2 | totals3
-----------------------------------
sales 500 500 500
returns 100 100 100
total 650 650 650
所以我知道我可以
@foreach $RootData as $data
@foreach $data as $key=>value
@endforeach
@endforeach
这将给我一个内部数据的结果,但是我希望能够使用内部的级别
innerData