This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

How to Get Last Segment From Url In Codeigniter?

How to Get Last Segment From Url In Codeigniter? Codeigniter,url How to Get Last Segment From Url In Codeigniter?

I need to get the value of last URI / URL segment in Codeigniter today and I came up with this easy solutions. It permits you to retrieve a last segment from the URI. ALL three alternative works like charm.
Alternative 1:

 $last = end($this->uri->segments); //Where, segments is a class variable. 
Alternative 2:
 $last = end($this->uri->segment_array()); 
Alternative 3:
 $total = $this->uri->total_segments(); $last = $this->uri->segment($total); 

0 Response to "How to Get Last Segment From Url In Codeigniter?"

Posting Komentar

Contact

Nama

Email *

Pesan *