First change the arr2 so its index is the autoid
then you can use it easily to get the progress value.
Then just foreach over arr1 and apply changes to progress
if they exist
$arr1 = [
['autoid' => 't35wmkbg','task' => 'Zaphod','progress' => 'incomplete'],
['autoid' => 'cwg2yc5q', 'task' => 'Arthur', 'progress' => 'incomplete'],
['autoid' => '85q4bcmy', 'task' => 'Ford', 'progress' => 'incomplete'],
['autoid' => 'yc5qcwg2', 'task' => 'Trillian', 'progress' => 'incomplete']
];
$arr2 = [
['autoid' => 't35wmkbg', 'task' => 'Zaphod', 'progress' => 'complete'],
['autoid' => '85q4bcmy', 'task' => 'Ford', 'progress' => 'incomplete'],
['autoid' => 'cwg2yc5q', 'task' => 'Arthur', 'progress' => 'pending']
];
#first make arr2 indexable on the autoid
foreach ($arr2 as $a) {
$arr2search[$a['autoid']] = $a;
}
foreach ($arr1 as $a){
// do we have an autoid in arr2
if ( isset($arr2search[$a['autoid']])){
$a['progress'] = $arr2search[$a['autoid']]['progress'];
}
$merged[] = $a;
}
print_r($merged);
RESULT
Array
(
[0] => Array
([autoid] => t35wmkbg, [task] => Zaphod, [progress] => complete)
[1] => Array
([autoid] => cwg2yc5q, [task] => Arthur, [progress] => pending )
[2] => Array
([autoid] => 85q4bcmy, [task] => Ford, [progress] => incomplete )
[3] => Array
([autoid] => yc5qcwg2, [task] => Trillian, [progress] => incomplete )
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…