I want to count total number of segments in codeigniter so I can display error if user/visitor enter additional segment in my url.
Asked
Active
Viewed 5,558 times
1 Answers
7
Have you checked the manual yet? There is such method that will get the total segments. $this->uri->total_segments()
Or also you can use $this->uri->segment_array()
.
$total = count($this->uri->segment_array());

user1978142
- 7,946
- 3
- 17
- 20