Functions Taking Variable Number Of Arguments In PHP - Online Code

Description

Suppose, we want to define a function that takes a variable number of arguments. We will create a function that uses func_get_args( ) to return an array containing all the values passed to the function. Look at the code.

Source Code

// find the average of a group of numbers
function average()
{
    $sum = 0;

    // load the arguments into $numbers using PHP's built in function func_get_args().
    $numbers = func_get_args();

    // the number of 
... (login or register to view full code)

To view full code, you must Login or Register, its FREE.

Hey, registering yourself just takes less than a minute and opens up a whole new GetGyan experience.




Comments

No comment yet. Be the first to post a comment.