title: Compute array intersection, preserve header order?
body: <p>I have two arrays:</p>
  
  <pre><code>&lt;?php
  $row = array(
    'useless' =&gt; 42,
    'useful' =&gt; 'orange',
    'useful_also' =&gt; 'apples',
    'useless_too' =&gt; 'banana',
    'useful_too' =&gt; 'apples');
  $header = array('useful_too', 'useful', 'useful_also');
  </code></pre>
  
  <p>How can I get the following array?</p>
  
  <pre><code>   &lt;?php
     $result = array(
        'useful_too' =&gt; 'apples',
        'useful'     =&gt; 'orange',
        'useful_also' =&gt; 'apples'
     );
  </code></pre>
  
  <p>I was using <code>array_intersect_key</code>, but it would not use the second
  array order, but the first. I guess I'll use a simple foreach for the
  moment, like this:</p>
  
  <pre><code>&lt;?php
  $result = array();
  foreach ($header as $key) {
      $result[$key] = $row[$key];
  }
  </code></pre>
  
  <p>but I was wondering if there was a solution without a foreach.</p>