一开始的代码
foreach ($list as $key => $value) {
$where = array(
'id' => intval($value['product_id'])
);
$detail = $this->detail('product', $where);
$value['product_name'] = $detail['title'];
}
修改之后
foreach ($list as $key => &$value) {
$where = array(
'id' => intval($value['product_id'])
);
$detail = $this->detail('product', $where);
$value['product_name'] = $detail['title'];
}
不同:在$value前面添加地址符&