title: PHP foreach loop key value
body: <p>I am running this DB call to get me multi-dimensional array
  I am trying to get the keys of each but when I try it comes up blank or as array.   </p>
  
  <pre><code>$root_array = array();
  $sites = $this-&gt;sites($member_id);
  foreach ($sites as $site){
      $records = $this-&gt;db-&gt;select('p.name as place_name, p.id as place_id,p.active as place_status')
                  -&gt;from('places p')
                  -&gt;join('members_permissions pm','pm.sites_id = p.sites_id and pm.members_id ='.$member_id)
                  -&gt;where('p.active', 0)
                  -&gt;get();
  
      $places = $records-&gt;result_array();
      $places['name'] = $site['name'];
      foreach($places as $place){
         $root_array[$site['name']][] = $place;
      }
  
  }
  return $root_array;
  </code></pre>
  
  <p>here is my php that loops through:</p>
  
  <pre><code>&lt;?php foreach($places as $site): ?&gt;
      &lt;h5&gt;&lt;?=key($site)?&gt;&lt;/h5&gt;
          &lt;?php foreach($site as $place): ?&gt;
              &lt;h6&gt;&lt;?=$place['place_name']?&gt;&lt;/h6&gt;
          &lt;?php endforeach?&gt;
  
  &lt;?php endforeach ?&gt;
  </code></pre>
  
  <p>Also when I run a test which just spits out the array this is the result,
  What I am trying to render is <strong>[Philadelphia]</strong></p>
  
  <pre><code>[Philadelphia] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [place_name] =&gt; XYX
                      [place_id] =&gt; 103200
                      [place_status] =&gt; 0
                  )
  
              [1] =&gt; Array
                  (
                  [place_name] =&gt; YYYY
                  [place_id] =&gt; 232323
                  [place_status] =&gt; 0
              )
  </code></pre>