我有以下代码:
@foreach($data['daily'] as $date => $dailyData)
<tr>
<td>{{$date}}</td>
@foreach($dailyData as $key => $value)
<td>
<span>{{$value}}</span>
<strong>{{$data['another_index'][$date][$key]}}</strong>
</td>
@endforeach
</tr>
@endforeach
这给我一个错误
[ErrorException]
Undefined index: date
执行代码时。实际上我在another_index
有值,我可以打印它。
提前感谢您的帮助。
[another_index] => Array
(
[2016-03-15] => Array
(
[key] => 100.00%
[key1] => 0.00%
[key2] => 0.00%
)
[2016-03-14] => Array
(
[key] => 10.00%
[key1] => 20.00%
[key2] => 30.00%
)
答案 0 :(得分:0)
查看您的示例数组,这应该会为您提供您尝试实现的目标:
@foreach($data as $date => $dailyData)
<tr>
<td>{{$date}}</td>
@foreach($dailyData as $key => $value)
<td>
<span>{{$key}}</span>
<strong>{{$value}}</strong>
</td>
@endforeach
</tr>
@endforeach