title: Find a key => value in multidimensional array but return parent key?
body: <p>I am trying to loop through an array, and return a key and child array of an array which has a set key => value.</p>
  
  <p>For example...</p>
  
  <p>Let's say I have</p>
  
  <pre><code>array(0 =&gt; array("chicken" =&gt; "free"), 1 =&gt; array("chicken" =&gt; "notfree"));
  </code></pre>
  
  <p>And I want to get the array <code>array("chicken" =&gt; "notfree")</code> and know that the parent key is <code>1</code></p>
  
  <p>I have the following...</p>
  
  <pre><code>function search($array, $key, $value) {
      $arrIt = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
  
      foreach($arrIt as $sub) {
          $subArray = $arrIt-&gt;getSubIterator();
          $subKey = $arrIt-&gt;key();
          if(isset($subArray[$key]) &amp;&amp; $subArray[$key] === $value) {
              return array("key" =&gt; $subKey, "array" =&gt; iterator_to_array($subArray));
          }
      }
  }
  </code></pre>
  
  <p>I can easily get the <code>"chicken" =&gt; "notfree"</code>, but I can't seem to get the parent key, <code>$arrIt-&gt;key()</code> keeps returning null? Any ideas?</p>