继承了数组结构,但我不知道如何在foreach循环中访问它 但我不知道我在这做什么 对我们差不多十二岁的人来说,我很沮丧
Array
(
[30] => Array
(
[166] => Array
(
[0] => Array
(
[loan_id] => 166
[loan_fullname] => Albano, Zester Quinn
[loan_amount] => 5000
[loan_interest] => 5
[loan_total_amount] => 5250
[loan_collectables] => 2
[loan_user_id] => 30
)
[82] => Array
(
[0] => Array
(
[coll_id] => 81
[coll_date] => 2017-05-26
[coll_amount] => 2625
[coll_loan_id] => 166
[coll_user_id] => 30
)
[1] => Array
(
[coll_id] => 82
[coll_date] => 2017-05-28
[coll_amount] => 2625
[coll_loan_id] => 166
[coll_user_id] => 30
)
)
)
[167] => Array
(
[0] => Array
(
[loan_id] => 167
[loan_fullname] => Albano, Zester Quinn
[loan_amount] => 5000
[loan_interest] => 5
[loan_total_amount] => 5250
[loan_collectables] => 2
[loan_user_id] => 30
)
[84] => Array
(
[0] => Array
(
[coll_id] => 83
[coll_date] => 2017-05-28
[coll_amount] => 2625
[coll_loan_id] => 167
[coll_user_id] => 30
)
[1] => Array
(
[coll_id] => 84
[coll_date] => 2017-05-28
[coll_amount] => 2625
[coll_loan_id] => 167
[coll_user_id] => 30
)
)
)
[168] => Array
(
[0] => Array
(
[loan_id] => 168
[loan_fullname] => Albano, Zester Quinn
[loan_amount] => 2121
[loan_interest] => 2
[loan_total_amount] => 2163
[loan_collectables] => 1
[loan_user_id] => 30
)
[85] => Array
(
[0] => Array
(
[coll_id] => 85
[coll_date] => 2017-05-21
[coll_amount] => 2163
[coll_loan_id] => 168
[coll_user_id] => 30
)
)
)
)
[31] => Array
(
[169] => Array
(
[0] => Array
(
[loan_id] => 169
[loan_fullname] => Dy, Adrian Kim
[loan_amount] => 5000
[loan_interest] => 2
[loan_total_amount] => 5100
[loan_collectables] => 2
[loan_user_id] => 31
)
[87] => Array
(
[0] => Array
(
[coll_id] => 86
[coll_date] => 2017-05-28
[coll_amount] => 2550
[coll_loan_id] => 169
[coll_user_id] => 31
)
[1] => Array
(
[coll_id] => 87
[coll_date] => 2017-05-29
[coll_amount] => 2550
[coll_loan_id] => 169
[coll_user_id] => 31
)
)
)
)
)
继承了我的观点,但它说未知的loan_id 在我的foreach中,我不知道如何使用每个元素的数组中的数组访问数组
<?php foreach($loans as $row) : ?>
<tr>
<td class="text-center"><?= $loans['loan_id'] ?></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center">
<td class="text-center"></td>
<tr>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
</tr>
</td>
</tr>
<?php endforeach; ?>
我不知道该怎么办..请帮助我..我在这里呆了将近12个小时 我怎么能解决这个问题?
Array
(
[166] => Array
(
[0] => Array
(
[loan_id] => 166
[loan_fullname] => Albano, Zester Quinn
[loan_amount] => 5000
[loan_interest] => 5
[loan_total_amount] => 5250
[loan_collectables] => 2
[loan_user_id] => 30
)
[82] => Array
(
[0] => Array
(
[coll_id] => 81
[coll_date] => 2017-05-26
[coll_amount] => 2625
[coll_loan_id] => 166
[coll_user_id] => 30
)
[1] => Array
(
[coll_id] => 82
[coll_date] => 2017-05-28
[coll_amount] => 2625
[coll_loan_id] => 166
[coll_user_id] => 30
)
)
)
[167] => Array
(
[0] => Array
(
[loan_id] => 167
[loan_fullname] => Albano, Zester Quinn
[loan_amount] => 5000
[loan_interest] => 5
[loan_total_amount] => 5250
[loan_collectables] => 2
[loan_user_id] => 30
)
[84] => Array
(
[0] => Array
(
[coll_id] => 83
[coll_date] => 2017-05-28
[coll_amount] => 2625
[coll_loan_id] => 167
[coll_user_id] => 30
)
[1] => Array
(
[coll_id] => 84
[coll_date] => 2017-05-28
[coll_amount] => 2625
[coll_loan_id] => 167
[coll_user_id] => 30
)
)
)
[168] => Array
(
[0] => Array
(
[loan_id] => 168
[loan_fullname] => Albano, Zester Quinn
[loan_amount] => 2121
[loan_interest] => 2
[loan_total_amount] => 2163
[loan_collectables] => 1
[loan_user_id] => 30
)
[85] => Array
(
[0] => Array
(
[coll_id] => 85
[coll_date] => 2017-05-21
[coll_amount] => 2163
[coll_loan_id] => 168
[coll_user_id] => 30
)
)
)
)
答案 0 :(得分:0)
<?php
foreach ($loans as $key) {
foreach ($key as $key1) {
foreach ($key1 as $key2) {
if(@$key2['loan_id'] != ''){
?>
<tr>
<td class="text-center"><?php echo @$key2['loan_id']; ?></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center">
<td class="text-center"></td>
<tr>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
</tr>
</td>
</tr>
<?php
}
}
}
}
?>