我有嵌套的数据数组
在hire中,如何向数组['data']推送新的值?
我拥有的数据是一个对象,我想将数据插入每个数组
[
{
"divisi" : 01,
"data": [
{
"status": "MUNDUR",
"total": "0"
}
]
},
{
"divisi" : 02,
"data": [
{
"status": "BATAL",
"total": "0"
}
]
},
{...},
{...},
]
后果
{
"divisi" : 01,
"data": [
{
"status": "BATAL",
"total": "0"
},
{
"status": "WIN", // new push
"total": "0"
}
]
},
这是我的密码
public function detail_get(){
$divisi = $this->M_model->db_tbl_divisi();
$data =array();
foreach ($divisi as $row){
$i = $this->M_model->db_realisasi_divisi($row['divisi_kode']);
$win = $this->M_model->db_win_win($row['divisi_kode'],'win'); // how to push ?
$data[] = array(
'divisi' => $row['kode'], // 01,02
'data' => $i
);
}
$response = $this->set_response($data,200);
}
我有密码
$win = $this->M_model->db_win_win($row['divisi_kode'],'win');
value object
{
"status": "win",
"total": "1"
}
我有一个数据对象,我想插入到['data']
怎么做