vriadic function in php
<?php
function sum(int ...$numbers): int
{
$total = 0;
for ($i = 0; $i < count($numbers); $i++) {
$total += $numbers[$i];
}
return $total;
}
Code language: PHP (php)
vriadic function in php
<?php
function sum(int ...$numbers): int
{
$total = 0;
for ($i = 0; $i < count($numbers); $i++) {
$total += $numbers[$i];
}
return $total;
}
Code language: PHP (php)
vriadic function in php
<?php
function sum(...$numbers)
{
$total = 0;
for ($i = 0; $i < count($numbers); $i++) {
$total += $numbers[$i];
}
return $total;
}
echo sum(10, 20) . '<br>'; // 30
echo sum(10, 20, 30) . '<br>'; // 60
Code language: PHP (php)
vriadic function in php
<?php
function sum(int ...$numbers): int
{
return array_sum($numbers);
}
Code language: PHP (php)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us