title: Filter a multidemensional array
body: <p>I have an array that looks kinda like this:</p>
  
  <pre><code>array(1) { ["Special"]=&gt; array(4) { [0]=&gt; array(2) { ["ID"]=&gt; int(1) ["Visitors"]=&gt; int(2) } [1]=&gt; array(2) { ["ID"]=&gt; int(4) ["Visitors"]=&gt; int(5) } [2]=&gt; array(2) { ["ID"]=&gt; int(169) ["Visitors"]=&gt; int(0) } } } 
  </code></pre>
  
  <p>How can I filter it by 'ID' value, so the result would be looking like this (if I need to get arrays with ID = 4): </p>
  
  <pre><code>array(1) { ["Special"]=&gt; array(4) { [1]=&gt; array(2) { ["ID"]=&gt; int(4) ["Visitors"]=&gt; int(5) } } } 
  </code></pre>
  
  <p>I tried to use that function, but it doesn't return what I need:</p>
  
  <pre><code>function search($array, $key, $value) {
  $results = array();
  
  if (is_array($array)) {
      if (isset($array[$key]) &amp;&amp; $array[$key] == $value) {
  
          $results[] = $array;
      }
  
      foreach ($array as $subarray) {
          $results = array_merge($results, search($subarray, $key, $value));
      }
  }
  
  return $results; }
  </code></pre>