Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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)
Source by www.phptutorial.net #
 
PREVIOUS NEXT
Tagged: #vriadic #function #php
ADD COMMENT
Topic
Name
8+7 =