Answers for "php function with undefined amount of params"

PHP
0

php function with undefined amount of params

function sum() {
  	// args looks like: array(1,2,3)
    $args = func_get_args();  
    return array_sum($args);
}

echo sum(1,2,3);   // prints 6
Posted by: Guest on March-27-2021

Code answers related to "php function with undefined amount of params"

Browse Popular Code Answers by Language