大批 Array ( [1] => stdClass Object ( [id] => 1 [reg_type_id] => birth [mem_tbl_id] => 1 [reg_date] => 1937-09-18 ) [2] => stdClass Object ( [id] => 3 [reg_type_id] => birth [mem_tbl_id] => 2 [reg_date] => 1945-02-06 ) [3] => stdClass Object ( [id] => 4 [reg_type_id] => birth [mem_tbl_id] => 3 [reg_date] => 1968-04-12 ) )需要将“reg_date”重命名为“do_birth”我尝试更改密钥但出现“无法将 stdClass 类型的对象用作数组”错误。foreach ($birth as $k => $v) { $birth[$k] ['do_birth'] = $birth[$k] ['reg_date']; unset($birth[$k]['reg_date']); }以上几行代码对我不起作用!
1 回答
守候你守候我
TA贡献1802条经验 获得超10个赞
您不能使用以下代码获取对象作为数组
foreach ($birth as $k => $v) {
$birth[$k]->do_birth = $birth[$k]->reg_date;
unset($birth[$k]->reg_date);
}
- 1 回答
- 0 关注
- 100 浏览
添加回答
举报
0/150
提交
取消