$a = [
'0' => [
'a' => '11',
'b' => '22',
'c' => '33'
],
'1' => [
'a' => '44',
'b' => '55',
'c' => '66'
],
...
];
PHPz2017-05-27 17:45:55
No, and it makes no sense.
No matter what, you have to loop in disguise to achieve traversal.
淡淡烟草味2017-05-27 17:45:55
For another method, even if you don’t need a loop, then that method must also use a loop
SoChange the soup but not the medicine
PHPz2017-05-27 17:45:55
The order upstairs is messed up. It should be array_map(function,$arr);
In fact, what you said upstairs is correct. Built-in functions need to traverse the entire array. How should you use built-in functions to solve your problem?
$a=array_map(function($val){
$val['b']='99';
return $val;
},$a);
伊谢尔伦2017-05-27 17:45:55
Boring, not grasping the big picture, getting hung up on minutiae. So I’m bored too, 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));