Welcome Guest, Not a member yet? Register   Sign In
URI Slash Segment Problem
#1

[eluser]Unknown[/eluser]
I'm trying to build a string of the first 2 segments in my URL.
Code:
http://example.com/news/local/

I was going to concatenate the 2 segments (shown below) but realised that I'd get a double slash like http://example.com/news// at the end if the 2nd segment wasn't present.
Code:
$this->uri->segment(1) . '/' . $this->uri->segment(2) . '/';

I was then going to use slash_segments to acheive the desired outcome but this is returning the same problem.

I thought that if the segment didn't exist then the segment would return FALSE?
Code:
http://example.com/news/

Taking the above URL as an example, and using the slash_segments function:
Code:
$this->uri->slash_segment(1) . $this->uri->slash_segment(2);

The above returns
Code:
news//

Seen as though the second segment is not present, should it not be returning
Code:
news/

I don't know if this is a potential bug in the slash_segment function - e.g. it adding the slash first before checking whether the segment contains a value?

Any thoughts are greatly appreciated.
Regards.




Theme © iAndrew 2016 - Forum software by © MyBB