title: Find key in nested associative array
body: <p>The other day I asked a question related to this, and I got an answer, but it did not do what I wanted.  Here is the method I have for traversing a multidimensional associative array, checking whether a key is in the array (from the answer to my previous question):</p>
  
  <pre><code>private function checkKeyIsInArray($dataItemName, $array)
  {
      foreach ($array as $key =&gt; $value)
      {
          // convert $key to string to prevent key type convertion
          echo '&lt;pre&gt;The key: '.(string) $key.'&lt;/pre&gt;';
  
          if ((string)$key == $dataItemName)
              return true;
  
          if (is_array($value))
              return $this-&gt;checkKeyIsInArray($dataItemName, $value);
  
      }
      return false;
  }
  </code></pre>
  
  <p>Here is my array stucture: </p>
  
  <pre><code>Array (
      [0] =&gt; Array ( [reset_time] =&gt; 2013-12-11 22:24:25 )
      [1] =&gt; Array ( [email] =&gt; someone@example.com )
  )
  </code></pre>
  
  <p>The method traverses the first array branch, but not the second. Could someone explain why this might be the case please? It seems I am missing something.</p>