I’m new to codeigniter 2, and I have a question about URI segments.
What should I do when I have a different number of segments?
for example (pseudo code)
if(number of segments are 3){
do something
}elseif(number of segmens are only 2){
do something else
}
The number of segments is really only relevant to the application and shouldn’t really be in your code. You use them by assigning variables to them. So say you had an order list and you wanted the ability to edit it. You could have a url like myorders/edit_order/12 then in the controller you’d use that segment like this:
I really can’t see a reason why you’d need to know the number of segments, just which segment holds the data you’re passing.