0

I'm trying to call a function and pass an infinite amount of parameters from an array. This is for use in an HMVC framework to call the controller and pass X amount of parameters so I also welcome any better approaches to this as well.

I'm calling my function like this where $params is an array of a potentially infinite amount of values:

controller::$action($params);

Then the params would be fully configurable by the programmer in the controller. This would be my example for the edit action:

public static function edit($id = false, $group = 'default', etc.){
   // Something
}
1

1 Answer 1

-1
function edit ($args) {
   foreach ($args as $arg) {
      echo "Arg = ".$arg;
   }
}

$params = array($id, $group, etc...);
call_user_func_array("edit", array($params));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.