title: Can't retrieve associative array index in php
body: <p>I have an array that looks like the following: </p>
  
  <pre><code>array(3) { [0]=&gt; array(1) 
  { 
  ["habitacionales"]=&gt; array(1) 
  { ["Azcapotzalco"]=&gt; string(1) "3" } } 
  [1]=&gt; array(1) { ["comerciales"]=&gt; array(0) { } } 
  [2]=&gt; array(1) { ["industriales"]=&gt; array(0) { } }
  }
  </code></pre>
  
  <p>And I need to check if the array belongs to the type "habitacionales", or "comerciales", etc. But no matter what I do, I keep getting the notice "Undefined index: habitacionales". Could someone point out how to access that index? </p>
  
  <p>I am using cakephp, and I am setting the variables in the controller like this: </p>
  
  <pre><code>$zonasHab = $this-&gt;PropiedadesHabitacionale-&gt;BasicosPropiedadesHabitacionale-&gt;find('list', array('fields'=&gt;array('Zona', 'propiedad_habitacional_id')));
  </code></pre>
  
  <p>then I do: </p>
  
  <pre><code>$this-&gt;set('Zonas', array_unique($linksZonas, SORT_REGULAR));
  </code></pre>
  
  <p>And finally in the view I do: </p>
  
  <pre><code>foreach ($Zonas as $zona) {
                          foreach($zona as $zone) {
                          foreach(array_flip($zone) as $link)   {
                          echo '&lt;li   class="dropdownheader"&gt;'.$link;
                          }
  
  
                          var_dump($zone['habitacionales']);
                          }/*
                          if($zona['habitacionales']!=null) 
                          foreach(array_flip($zone) as $vinculo) {
                          echo '&lt;li&gt;'.$this-&gt;Html- &gt;link($vinculo, array('controller'=&gt;'propiedadeshabitacionales', 'action'=&gt;'ver', $vinculo)).'&lt;/li&gt;';
                          }
                          */
                          echo '&lt;/li&gt;'; 
  } 
  </code></pre>
  
  <p>Just to point out, the wierd thing is that if I do <code>var_dump($zona['habitacionales']);</code> inside the outer <code>foreach</code>, I get the correct value: array(1) { ["Azcapotzalco"]=> string(1) "3" } but I still get the notice appearing telling me it's an undefined index, and I can't use that same syntax ($zona['habitacionales'] for a condition or anything else.</p>