title: How do I remove keys from an array which are not in another array?
body: <p>I have the following two arrays:</p>
  
  <blockquote>
    <p><strong>EDIT</strong></p>
    
    <p>On suggestion from @Wrikken I've
    cleaned the first array and now have
    this:</p>
  </blockquote>
  
  <p><strong>First Array:</strong></p>
  
  <pre><code>Array
  (
      [0] =&gt; 3
      [1] =&gt; 4
      [2] =&gt; 9
      [3] =&gt; 11
  )
  </code></pre>
  
  <p><strong>Second Array:</strong></p>
  
  <pre><code>Array
  (
      [3] =&gt; stdClass Object ( [tid] =&gt; 3 )
  
      [12] =&gt; stdClass Object ( tid] =&gt; 12 )
  
      [9] =&gt; stdClass Object ( [tid] =&gt; 9 )
  )
  </code></pre>
  
  <blockquote>
    <p><strong>EDIT</strong></p>
    
    <p>The second array is being filtered on
    the first array. The second array has
    3, 12, 9. The first array doesn't
    contain 12, so 12 should be removed
    from the second array.</p>
  </blockquote>
  
  <p>So I should end up with:</p>
  
  <pre><code>Array
  (
      [3] =&gt; stdClass Object ( [tid] =&gt; 3 )
  
      [9] =&gt; stdClass Object ( [tid] =&gt; 9 )
  )
  </code></pre>