ExpressionEngine CMS
Open, Free, Amazing


This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Get value of "Last " URI / URL segment with total_segments

April 11, 2008 5:41am

Subscribe [3]
  • #1 / Apr 11, 2008 5:41am

    geshan's avatar


    54 posts

    A code like below:

    //in library
    $offset= $this->CI->uri->segment($ts);    
    //in controller
    $offset= $this->uri->segment($ts);

    This gives you the value of the last segment of your URL, it is very useful when you paginate and need the value of the offset.


  • #2 / Apr 11, 2008 5:54am


    4145 posts

    I was looking for the same thing today but for another purpose. I came up with this solution

    $last = end($this->uri->segments);

    segments is a class variable.

  • #3 / Apr 11, 2008 6:09am

    geshan's avatar


    54 posts

    I didn’t know about end well I’ll see what it does as well, thanks.


  • #4 / Aug 12, 2013 12:53pm

    seotags's avatar


    1 posts


    You could use something like this to query the last part of an url.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases