Suppose I\'ve the following function:
function mul()
{
return array_reduce(func_get_args(), \'*\');
}
Is is possible to use the * operat
In this specific case, use array_product():
function mul() {
return array_product(func_get_args());
}
In the general case? No, you can't pass an operator as a callback to a function. You would at least have to wrap it in a function:
function mul() {
return array_reduce(func_get_args(), 'mult', 1);
}
function mult($a, $b) {
return $a * $b;
}