$a = [
'0' => [
'a' => '11',
'b' => '22',
'c' => '33'
],
'1' => [
'a' => '44',
'b' => '55',
'c' => '66'
],
...
];
PHPz2017-05-27 17:45:55
樓上的順序弄亂了,應該 array_map(function,$arr);
其實樓上說得都沒錯,內建函數都係需要遍歷整個數組,你的問題應該如何使用內建函數實現
$a=array_map(function($val){
$val['b']='99';
return $val;
},$a);
伊谢尔伦2017-05-27 17:45:55
無聊,大的方向不去把握,糾結於細枝末節。所以我也無聊一把吧,haha
$arr = [
'0' => [
'a' => '11',
'b' => '22',
'c' => '33'
],
'1' => [
'a' => '44',
'b' => '55',
'c' => '66'
]
];
$arr = json_encode($arr);
$match = preg_replace('/"b":"(.+?)"/', '"b":"99"', $arr);
var_dump(json_decode($match, true));