Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter - unlimited parameters?

I am currently using CodeIgniter.

I am trying to write a function that can take an unlimited number of paramaters.

So in the controller it will be something like

function test($name, $others){
    foreach($others){
       //do something
    }
}

and I could call it like

example.com/control/test/some name/param1/param2/param3/param4/param5... 

How can I set this up?

like image 548
Hailwood Avatar asked Nov 21 '10 09:11

Hailwood


1 Answers

you could also do it like this:

function foo($params=array())
{
    $params=func_get_args();
    //print_r($params);
}

so any url like:

site.com/controller/foo/param1/param2/param3/param4

would create an array of parameters.

like image 64
Ross Avatar answered Sep 25 '22 03:09

Ross