getting the uri segments |
[eluser]basty_dread[/eluser]
Hello there. I am new to CI. i was able to pass this uri segments to the address bar using a javascript. ex: http://localhost/page/index.php/keywords/popup/one/this two/this is three/amps/four my propblem is i want to echo the segments after /popup/ which is /one/,/this two/ and up to the last which is /four i want to assign it to an array but i dont know how. this values -----> /one/this two/this is three/amps/four because i will insert it to my database. im sorry for my english. i hope you all understand what i am talking about. Thank you very much for anyone who will help.
[eluser]rogierb[/eluser]
Did you read the userguide? The part about the "URI Class" might interest you.
[eluser]basty_dread[/eluser]
ohhh... what could be the code for looping? and putting this values to an array? thank you rogierb for posting.
[eluser]daparky[/eluser]
$this->uri->segment(n) Permits you to retrieve a specific segment. Where n is the segment number you wish to retrieve. Segments are numbered from left to right. For example, if your full URL is this: http://example.com/index.php/news/local/...rime_is_up The segment numbers would be this: 1. news 2. local 3. metro 4. crime_is_up By default the function returns FALSE (boolean) if the segment does not exist. There is an optional second parameter that permits you to set your own default value if the segment is missing. For example, this would tell the function to return the number zero in the event of failure: $product_id = $this->uri->segment(3, 0);
|
Welcome Guest, Not a member yet? Register Sign In |