Welcome Guest, Not a member yet? Register   Sign In
Empty URI Segments
#1

[eluser]SitesByJoe[/eluser]
Greetings all,

I have a question about empty segments. Here's what's going on:

I have a URL like this:
http://seaislerealty.com/index.php/renta.../////.p/.i

I need my controller to change it into a querystring-based equivalent, then use curl to grab another script from the server with the string. (secretly shhhh)

Sometimes the segments will contain something, sometimes they'll be empty and I need to account for both.

Here's the snippet from my controller that does this:

Code:
// build our new url from the segments
$url = 'http://seaislerealty.com/cgi-bin/SBJRESULTS?';
$url .= 'ryear=' . $this->uri->segment(3);
$url .= '&rbeds;=' . $this->uri->segment(4);
$url .= '&rbaths;=' . $this->uri->segment(5);
$url .= '&which;=' . $this->uri->segment(6);
$url .= '&rperiod;=' . $this->uri->segment(7);
$url .= '&rweeks;=' . $this->uri->segment(8);
$url .= '&rperiod2;=' . $this->uri->segment(9);
$url .= '&beach;=' . $this->uri->segment(10);
$url .= '&rday;=' . $this->uri->segment(11);
$url .= '&petsok;=' . $this->uri->segment(12);
$url .= '&elevator;=' . $this->uri->segment(13);
$url .= '&internet;=' . $this->uri->segment(14);
$url .= '&rprice;=' . $this->uri->segment(15);
$url .= '&sortfld;=' . $this->uri->segment(16);
$url .= '&anyweek;=' . $this->uri->segment(17);
$url .= '&agentcode;=' . $this->uri->segment(18);
$url .= '&uucode;=' . $this->uri->segment(19);
$url .= '&uaddrno;=' . $this->uri->segment(20);
$url .= '&pictures;=' . $this->uri->segment(21);
$url .= '&interact;=' . $this->uri->segment(22);

// now show the url
echo 'Output: ';
echo $url;
exit;

Its seems to work great, but it appears that CI is ignoring the empty segments and pulling the segments with values into the wrong position. For example, segment(22) should be ".i" as its value, but instead it moves up to segment(17).

Why is this?

Thanks!
#2

[eluser]Anthony Hull[/eluser]
Could you not change the input URL so that there are no empty segments? Just make the empty ones something like /---/

Anthony




Theme © iAndrew 2016 - Forum software by © MyBB