Creating Functions That Take a Variable Number of Arguments
<?php
function addanything (){
$total = 0;
$args = func_get_args ();
for ($i = 0; $i < count ($args); $i++){
if (is_int ($args[$i])){
$total += $args[$i];
}
}
return $total;
}
echo addanything (1,5,7,8,11) . "<br />";
?>
Related examples in the same category