2 ms·
it's not the best of both worlds though, splat should only be used on something where you're basically doing the same thing to a bunch of things. like add(1,2,
by gremlinsinc 6y ago
it's not the best of both worlds though, splat should only be used on something where you're basically doing the same thing to a bunch of things.
like add(1,2,3,4,5) ->
function add(...$nums){
$count = 0;
foreach($nums as $num) { $count += $num; }
}
If you know what arguments you're getting, then the more sound way would be just use an associative array, but either way you really don't get great type checking.
This is a much better solution.