title: How to get the last item of a nested array?
body: <p>I have this array:</p>
  
  <pre><code>$results = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  
  /*
  Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 191
              [range] =&gt; today
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 190
              [range] =&gt; today
          )
  
      [2] =&gt; Array
          (
              [id] =&gt; 189
              [range] =&gt; in last week
          )
  
      [3] =&gt; Array
          (
              [id] =&gt; 180
              [range] =&gt; in last week
          )
  
      [4] =&gt; Array
          (
              [id] =&gt; 170
              [range] =&gt; in last week                  &lt;- this
          )
  )
  */
  </code></pre>
  
  <p>I'm trying to get the vale of <code>range</code> which is last item. in this case it is <code>in last week</code>. Here is my code:</p>
  
  <pre><code>foreach ( $results as $item ) {
      $last_range_item = $item[range];
  }
  </code></pre>
  
  <p>My approach should work, but there is a lot of useless processes and overwriting. So is there any better way?</p>