In certain cases, you may require to pass different number of arguments to a function in PHP scripts. Let us consider a case where you want to calculate average of a set of values using a function. Number of values in the set may vary in each call to the function. PHP provides a mechanism to pass different number of arguments to a function and process the arguments from the function by using the following functions.
func_num_args() - Returns the number of arguments passes to the function
func_get_args() - Returns the arguments passed to the function as an array
func_get_arg($arg_num) - Returns the argument at the $arg_num th position or index . Starting index is 0.
func_num_args() - Returns the number of arguments passes to the function
func_get_args() - Returns the arguments passed to the function as an array
func_get_arg($arg_num) - Returns the argument at the $arg_num th position or index . Starting index is 0.
You can see the PHP implementation of the above problem
here.