<?php $a = [ ['rank' => '579', 'id' => '1'], ['rank' => '251', 'id' => '2'], ]; $b = [ ['size' => 'S', 'status' => 'A', 'id' => '1'], ['size' => 'L', 'status' => 'A', 'id' => '2'], ]; $result = []; foreach (array_merge($a, $b) as $row) { $result[$row['id']] = $row + ($result[$row['id']] ?? []); } var_export(array_values($result));
You have javascript disabled. You will not be able to edit any code.