Accessing function parameters without using the argument list : func_num_args « Functions « PHP






Accessing function parameters without using the argument list

 
<?
function mean() {
    $sum = 0;

    $size = func_num_args();

    for ($i = 0; $i < $size; $i++) {
        $sum += func_get_arg($i);
    }

    $average = $sum / $size;

    return $average;
}

$mean = mean(96, 93, 97);
?>
  
  








Related examples in the same category

1.Get parameter count from func_num_args ()
2.Variable Parameter Counts