简体   繁体   English

代码点火器-在最后一个URI段之前获取

[英]Code Igniter - Get Before Last URI Segment

I found on stackOverflow that I get the last segment can be found like this: 我在stackOverflow上发现我得到的最后一段可以像这样找到:

end($this->uri->segment_array());

There is a work around from the statement above to get the before last segment? 上面的语句有一个变通方法,可以得到最后一个段?

I'm not asking about 我不是在问

$this->uri->uri_to_assoc(n)

or 要么

$this->uri->segment(n)

Thank you. 谢谢。

Here's the segment before. 这是以前的片段。

$secondLastKey = count($this->uri->segment_array())-1;
$this->uri->segment($secondLastKey);
$segs = $this->uri->segment_array();
$number = count($segs)-2;
echo $segs[$number];
$last = $this->uri->segment($this->uri->total_segments());
$beforelast = $this->uri->segment($last--);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM