This works:
if (array_key_exists($key_to_check, $routes)) {
$uparts = explode('@', $routes[$key_to_check]);
$controller = isset($uparts[0]) ? $uparts[0] : null;
$action = isset($uparts[1]) ? $uparts[1] : null;
call_user_func_array(array($controller, $action), $last);
}
But I am trying to convert to variadic (splat operator), and the below does not work:
if (array_key_exists($key_to_check, $routes)) {
$uparts = explode('@', $routes[$key_to_check]);
$controller = isset($uparts[0]) ? $uparts[0] : null;
$action = isset($uparts[1]) ? $uparts[1] : null;
$controller->$action(...$last);
}
Anyone know how to properly replace the call_user_func_array with splat?
Note, $last is just the parameters being passed.
This is followup from Custom router question
I also tried:
$controller->{$action}(...array_values($last));
Thanks.