我構建一個數組是這樣的:無法訪問空屬性
$result = $this->db->get($this->_table);
foreach ($result->result_array() as $row)
{
$list->$row['categories_id'] = array('total_amount' => $row['total_amount'], 'other_stuff' => 'stuff');
}
這給了我致命異常「無法訪問空屬性」
<?foreach ($category_list as $index => $row) {?>
<td><?=$row?></td>
<td><?=$list->$index['total_amount']?></td>
<?}?>
但這個工程
<?foreach ($category_list as $index => $row) {?>
<td><?=$row?></td>
<? $temp = $list->$index; ?>
<td><?=$temp['total_amount']?></td>
<?}?>
有沒有更好的方法從這個對象中獲得「總量」?
更妙的是 - 我怎麼能做出這麼對象進行這樣
echo $list->$index->total_amount
請給完整的源代碼。例如,什麼是$行? –