Welcome Guest, Not a member yet? Register   Sign In
Pass url parts as array to controller
#1

[eluser]Unknown[/eluser]
Best,

I was wondering if it is possible to pass the whole url in array form to the called controller method.

so for example if I call
Code:
/controller/action/param1/param2/param3
I don't wish to catch those by creating

Code:
public function action($param1, $param2, $param3)

But rather

Code:
public function action($params)

This because I do not know in advance how many parameters will be passed through.

Thanks!
Pj
#2

[eluser]mschinis[/eluser]
you can use:
Code:
$this->uri->uri_to_assoc(n)

that will give you an associative array back. Refer to this page:
http://ellislab.com/codeigniter/user-gui...s/uri.html
#3

[eluser]Unknown[/eluser]
Hey mschinis,

uri_to_assoc wasn't exactly what I was looking for but on the page you provided I found the function

Code:
$this->uri->segment_array()

That did the job.

Thanks!
#4

[eluser]mschinis[/eluser]
Great :lol:

glad you figured it out Smile




Theme © iAndrew 2016 - Forum software by © MyBB