title: PHP array function that returns a subset for given keys
body: <p>I'm looking for an array function that does something like this:</p>
  
  <pre><code>$myArray = array(
    'apple'=&gt;'red',
    'banana'=&gt;'yellow',
    'lettuce'=&gt;'green',
    'strawberry'=&gt;'red',
    'tomato'=&gt;'red'
  );
  $keys = array(
    'lettuce',
    'tomato'
  );
  
  $ret = sub_array($myArray, $keys);
  </code></pre>
  
  <p>where $ret is:</p>
  
  <pre><code>array(
    'lettuce'=&gt;'green',
    'tomato'=&gt;'red'
  );
  </code></pre>
  
  <p>A have no problem in writing it down by myself, the thing is I would like to avoid foreach loop and adopt a built-in function or a combination of built-in functions. It seems to me like a general and common array operation - I'd be surprised if a loop is the only option.</p>