title: Compare two arrays and remove array from array in PHP
body: <p>I have two arrays and I need remove from bigger array smaller</p>
  
  <pre><code>$a = array(223 =&gt; 6, 381 =&gt; 6);
  </code></pre>
  
  <p>and second arrays is:</p>
  
  <pre><code>$b = array(array('id' =&gt; 45, 'username' =&gt; 'rock'), array('id' =&gt; 223, 'username' =&gt; 'pop'), array('id' =&gt; 381, 'username' =&gt; 'stock'));
  </code></pre>
  
  <p>With print_r() they looks like this</p>
  
  <pre><code>Array
  (
      [223] =&gt; 6
      [381] =&gt; 6
  )
  
  Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 45
              [username] =&gt; rock
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 223
              [username] =&gt; pop
          )
  
      [2] =&gt; Array
          (
              [id] =&gt; 381
              [username] =&gt; stock
          )
  
  )
  </code></pre>
  
  <p>How do I remove from $b array where id != $a[keys]
  So in result I will have array like this</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 223
              [username] =&gt; pop
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 381
              [username] =&gt; stock
          )
  
  )
  </code></pre>
  
  <p>I try to use array_diff, array_search and unset but do not know how make it work.</p>