title: PHP - Merge Two Associative Arrays where values match
body: <p>I have two arrays that need to be merged. I can loop through each array and merge manually. But, Is there a built in function to do this?</p>
  
  <p>Array 1:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [detail_image_id] =&gt; 6389
          [product_name] =&gt; Starter broadband Package
      )
  
  [1] =&gt; Array
      (
          [detail_image_id] =&gt; 6358
          [product_name] =&gt; Starter broadband Package
      )
  )
  </code></pre>
  
  <p>Array 2:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [detail_image_id] =&gt; 6358
          [guid] =&gt; http://xxx/wp-content/uploads/2018/04/broadband-4mbs-wingle.jpg
      )
  
  [1] =&gt; Array
      (
          [detail_image_id] =&gt; 6389
          [guid] =&gt; http://xxx/wp-content/uploads/2018/04/broadband-4mbs-charji.jpg
      )
  )
  </code></pre>
  
  <p>Expected Output array is:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [detail_image_id] =&gt; 6389
          [product_name] =&gt; Starter broadband Package
          [guid] =&gt; http://xxx/wp-content/uploads/2018/04/broadband-4mbs-charji.jpg
      )
  
  [1] =&gt; Array
      (
          [detail_image_id] =&gt; 6358
          [product_name] =&gt; Starter broadband Package
          [guid] =&gt; http://xxx/wp-content/uploads/2018/04/broadband-4mbs-wingle.jpg
      )
  )
  </code></pre>
  
  <p>I have added only a sample from the array. Array is huge. Is there any PHP functions like <code>array_merge()</code> or <code>array_map()</code> that we can use instead of manual for loops and iterators?</p>