PHP代码在线运行
<?php
$array = [
'a' => [
'a1' => 1,
'a2' => 2
],
'b' => [
'a1' => 1,
'a2' => 2
],
'c' => [
'a1' => 1,
'a2' => 2
]
];
foreach ($array as $k => $v) {
$array[$k]['a1'] = 11;
}
//foreach ($array as $k => &$v) {
// $v['a1'] = 11;
//}
print_r($array);