PHP二维数组追加修改二维数组数据
作者:互联网
1.foreach循环追加修改
foreach ($res as $k => $v) { $res[$k]['time'] = date('Y-M-D',$v['time']); }
2.循环引用追加修改
foreach ($res as $k => &$v) { $v['time'] = date('Y-M-D',$v['time']); }
3.使用array_walk追加修改
array_walk($res,function (&$v) { $v['time'] = date('Y-M-D',$v['time']);//方式1 $v = array_merge($v,['time'=>date('Y-M-D',$v['time'])]);//方式二 });
标签:res,二维,foreach,数组,time,date,array,PHP,追加 来源: https://www.cnblogs.com/lazb/p/15790985.html