Reputation: 1511
Is there a PhP function that can count the number of parameters passed to another function? for example
function tobeCounted ("numberOne","numberTwo","numberThree")
{
//do something with the parameters
}
a function that will count the number of parameters passed to the function above then return three or the indexes of the parameters or parameters themseleves.
Upvotes: 1
Views: 1055
Reputation: 13925
You need these:
func_num_args — Returns the number of arguments passed to the function
func_get_args — Returns an array comprising a function's argument list
From here:
http://www.php.net/manual/en/function.func-num-args.php
Upvotes: 2
Reputation: 1957
If you use func_num_args()
then you get the amount of arguments, rather than func_get_args
that gets you the array of arguments.
Upvotes: 3