title: How to get last key with values from array of arrays? PHP
body: <p>This is what i am currently using</p>
  
  <pre><code>&lt;?php $sidebar = $this-&gt;data['sidebar']; 
  $lastKey = array_pop(array_keys($sidebar));
  $sidebar = $this-&gt;data['sidebar'][$lastKey]; ?&gt;
  &lt;?php foreach($sidebar as $key =&gt; $item) { ?&gt;
  &lt;li id="&lt;?php echo Sanitizer::escapeId( "pt-$key" ) ?&gt;"&lt;?php
      if ($item['active']) { ?&gt; class="active"&lt;?php } ?&gt;&gt;&lt;a href="&lt;?php echo htmlspecialchars($item['href']) ?&gt;"&gt;&lt;?php echo htmlspecialchars($item['text']) ?&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>This is what i get (<a href="http://pastebin.com/t6Y2ZtMF" rel="nofollow">http://pastebin.com/t6Y2ZtMF</a>) when i <code>print_r($sidebar)</code>;
  I want to get the <strong>last Array</strong> which is <em>Categories</em> and turn it into links.</p>
  
  <p>I am new to php, so my method could be wrong even though it works. I is there a right way to pull the <em>Categories Array</em> or the above code is good as it is?</p>