I want to create a list of functions that can be run by a numerical variable without if statements.
I have tried to create an array and then store functions in that array as follows
$funcs = array();
$funcs[4] = function() {
//function code in here
}
and then to run the function I will do the following
$num = 4;
$funcs$num;
However, when I run the code I get the following error
Parse error: syntax error, unexpected T_FUNCTION
Does anyone know where I am going wrong or if there is an alternative way of achieving the same goal?
Any help would be great.