Get last segment
echo end($this->uri->segment_array()); //it will print others
Get before last segment
echo $this->uri->segment(count($this->uri->segment_array())-1); //it will print how-can-i-do-this
More info: [http://stackoverflow.com/questions/9221164/code-igniter-get-before-last-uri-segment][1]