Get parameter count from func_num_args () : func_num_args « Functions « PHP






Get parameter count from func_num_args ()

 
<?
function addNums() {
    $ret = "<table>";
    for ($x=0; $x<func_num_args (); $x++) {
        $arg = func_get_arg ($x);
        $result += $arg;
        $ret .= "<tr><td>number ". ($x+1).": </td><td>$arg</td></tr>";
    }
    $ret .= "<tr><td>result: </td><td>$result</td><tr>";
    $ret .= "</table>";
    return $ret;
}

print addNums (49, 60, 44, 22, 55);
?>
  
  








Related examples in the same category

1.Accessing function parameters without using the argument list
2.Variable Parameter Counts