title: matching multidimensional arrays by key value, preserving other values
body: <p>I have an array that contains data in the following format:</p>
  
  <pre><code>$myArray = array(
      array(
              'id' = 1,
              'title' = 'the first entry',
              'data' = 'additional data'
           ),
      array(
              'id' = 2,
              'title' = 'the third entry',
              'data' = 'some more data'
           ),
      array(
              'id' = 3,
              'title' = 'the second entry',
              'data' = 'other important stuff'
           )
      );
  </code></pre>
  
  <p>(An array containing about 12 child arrays in total). This data needs to be split into two rows for displaying on my page, based on the title attribute. I know what titles I want on the first row, and which ones for the second row. So I have another array like this:</p>
  
  <pre><code> $firstRow = array('the first entry', 'the second entry');
   $secondRow = array('the third entry');
  </code></pre>
  
  <p>So what I need to do is throw these 3 arrays, <code>$myArray, $firstRow, $secondRow</code> into a function which will output a new ordered array which preserves the other attributes (the <code>id</code> and <code>data</code> keys in my example) like the following:</p>
  
  <pre><code>$newArray = array(
      'firstRow' =&gt; array(
                        array(
                           'id' = 1,
                           'title' = 'the first entry',
                           'data' = 'additional data'
                              ),
                        array(
                           'id' = 2,
                           'title' = 'the second entry',
                           'data' = 'some more data'
                             )
                         ),
      'secondRow' =&gt; array(
                         array(
                            'id' = 3,
                            'title' = 'the third entry',
                            'data' = 'other important stuff'
                              )
                          )
                    );
  </code></pre>
  
  <p>I have some ideas, and I know there are various functions like array_intersect(), but I'm not sure which is the best to use? Hopefully someone has a quick and easy solution to this. Thanks.</p>