[eluser]frenzal[/eluser]
this is more of a general php issue rather than CI i guess. What i'm working on is a controller that depending on the page loads certain modules (libraries) and accesses a specific method (in the db as a content part) these content parts get stuck together forming some sort of page. Anyway I found on how to do the whole varaible function thing but I need a nice way to deal with my parameters. Right now i have this
Code:
switch(count($p)){
case 1: $function = $this->{$con["module"]}->{$con["function"]}($p[0]); break;
case 2: $function = $this->{$con["module"]}->{$con["function"]}($p[0], $p[1]); break;
case 3: $function = $this->{$con["module"]}->{$con["function"]}($p[0], $p[1], $p[2]); break;
case 4: $function = $this->{$con["module"]}->{$con["function"]}($p[0], $p[1], $p[2], $p[3]); break;
case 5: $function = $this->{$con["module"]}->{$con["function"]}($p[0], $p[1], $p[2], $p[3], $p[4]); break;
case 6: $function = $this->{$con["module"]}->{$con["function"]}($p[0], $p[1], $p[2], $p[3], $p[4], $p[5]); break;
default: $function = $this->{$con["module"]}->{$con["function"]}(); break;
}
Sure it works, but it feels so wrong. The array of parameters ($p) could contain any type or number of parameters depending on the funciton being called, all the parameter values are from the db too. Any suggestions, or generally a better way to deal with this thing?
Cheers