title: What is the most efficient way to combine this array of arrays in PHP?
body: <p>I'm trying to get two arrays of arrays (I think that means they're multidimensional) combined/merged together by a shared value. In other words, similar to the JOIN statement in SQL. Is there a specific, efficient way to go about this?</p>
  
  <p>Trying to merge these two:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; 5
              [1] =&gt; alice
              [2] =&gt; car
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; 3
              [1] =&gt; bob
              [2] =&gt; truck
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; 5
              [1] =&gt; charlie
              [2] =&gt; bike
          )
  
  )
  Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; 5
              [1] =&gt; alice
              [2] =&gt; Vancouver
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; 3
              [1] =&gt; bob
              [2] =&gt; Toronto
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; 5
              [1] =&gt; charlie
              [2] =&gt; Portland
          )
  
  )
  </code></pre>
  
  <p>To produce:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; 5
              [1] =&gt; alice
              [2] =&gt; car
              [3] =&gt; Vancouver
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; 3
              [1] =&gt; bob
              [2] =&gt; truck
              [3] =&gt; Toronto
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; 5
              [1] =&gt; charlie
              [2] =&gt; bike
              [3] =&gt; Portland
          )
  
  )
  </code></pre>