title: PHP merge arrays by value
body: <p>I know this is quite easily accomplished with a <code>foreach</code>, then a <code>while</code>->list, etc procedure, (I have already accomplished it), however I sense that my code is a bit dirty and it doesn't look like the best solution... I'm looking to use native PHP array functions to do the following:</p>
  
  <p>I have two arrays that look like this:</p>
  
  <pre>
  [0] (Array)#2
    [rank] "579"
    [id] "1"
  [1] (Array)#4
    [rank] "251"
    [id] "2"
  
  [0] (Array)#2
    [size] "S"
    [status] "A"
    [id] "1"
  [1] (Array)#15
    [size] "L"
    [status] "A"
    [id] "2"
  </pre>
  
  <p>And I need as a result something like the following:</p>
  
  <pre>
  [0] (Array)#2
    [size] "S"
    [status] "A"
    [id] "1"
    [rank] "579"
  
  [1] (Array)#2
    [size] "L"
    [status] "A"
    [id] "2"
    [rank] "251"
  </pre>
  
  <p>Is there a way to be able to merge two arrays with the <code>id</code> value (or ay other) without going into a endless set of <code>foreach</code>s?</p>