title: How to filter an array by a condition
body: <p>I have an array like this:</p>
  
  <pre><code>array("a" =&gt; 2, "b" =&gt; 4, "c" =&gt; 2, "d" =&gt; 5, "e" =&gt; 6, "f" =&gt; 2)
  </code></pre>
  
  <p>Now I want to filter that array by some condition and only keep the elements where the value is equal to 2 and delete all elements where the value is NOT 2.</p>
  
  <p>So my expected result array would be:</p>
  
  <pre><code>array("a" =&gt; 2, "c" =&gt; 2, "f" =&gt; 2)
  </code></pre>
  
  <p><sub>Note: I want to keep the keys from the original array.</sub></p>
  
  <p>How can I do that with PHP? Any built-in functions?</p>