Merge array where same key : <pre><code>I have following 2 arrays:

$arr1 = [
   0 =&gt; [
      'id' =&gt; 1,
      'name' =&gt; 'Peter',
   ],
   1 =&gt; [
      'id' =&gt; 2,
      'name' =&gt; 'John',
   ]
]

$arr2 = [
   0 =&gt; [
      'id' =&gt; 1,
      'surname' =&gt; 'Newman',
   ],
   1 =&gt; [
      'id' =&gt; 2,
      'surname' =&gt; 'Cena',
   ]
]
</code></pre>

<p>What I want to do is merge these arrays referencing on the same key. In this case I would like to merge them where the <code>id</code> is matching. So the output I would expect would be:</p>

<pre><code>$finalArr = [
       0 =&gt; [
          'id' =&gt; 1,
          'name' =&gt; 'Peter',
          'surname' =&gt; 'Newman',
       ],
       1 =&gt; [
          'id' =&gt; 2,
          'name' =&gt; 'John',
          'surname' =&gt; 'Cena',
       ]
    ]
</code></pre>

<p>I am using laravel but the language should not matter too much. I would like to use <code>collections</code> if possible.</p>
