PHP Ds / Sequence sum () function

PHP

Syntax:
number abstract public DsSequence::sum (void)
Parameters: This function takes no parameters.Return Value:This function returns the sum of all elements in a sequence as an integer or floating point.The programs below illustrate the Ds / Sequence::sum()function in PHP:Program 1:  
// Create new sequence $seq = new DsVector ([5, 7, 8, 14, 23]);  
// Use the sum() function to search
// sum of sequence element var_dump ( $seq -> sum());  
?>
Output:
int (57)
Program 2:  
// Create a new sequence $seq = new DsVector ([ 5, 7.5, 8.4, 14, 23]);  
// Use the sum() function to search
// sum of sequence element var_dump ( $seq -> sum());  
?>
Output:
float (57.9)
Link: http: //php.net/manual/en/ds-sequence.sum.php



Get Solution for free from DataCamp guru