title: CodeIgniter - Get Last URI Segment
body: <p>I'm trying to get the last URI segment in CI, however I don't know what the number for it will be, as parameters (an integer) will be appended as the user clicks links within the page. These are then used in a controller to pull relevant database records into the page via ajax.</p>
  
  <p>How can I tell CI to get the last segment?</p>
  
  <p>Something like:</p>
  
  <pre><code>$record_num = $this-&gt;uri-&gt;segment($last);
  </code></pre>