title: php extract sub array with specific key
body: <p>if i have the following array:</p>
  
  <pre><code>array(
     'var1' =&gt; 123,
     'var2' =&gt; 234,
     'var3' =&gt; 345
  );
  </code></pre>
  
  <p>I would like to extract specific parts of this to build a new array i.e. var1 and var3.</p>
  
  <p>The result i would be looking for is:</p>
  
  <pre><code>array(
     'var1' =&gt; 123,
     'var3' =&gt; 345
  );
  </code></pre>
  
  <p>The example posted is very stripped down, in reality the array has a much larger number of keys and I am looking to extract a larger number of key and also some keys may or may not be present.</p>
  
  <p>Is there a built in php function to do this?</p>
  
  <p>Edit:</p>
  
  <p>The keys to be extracted will be hardcoded as an array in the class i..e $this->keysToExtract</p>