PHP | Ds\Sequence sum() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Sequence::sum() function is an inbuilt function in PHP which is used to return the sum of all values of the sequence. Syntax: number abstract public Ds\Sequence::sum( void ) Parameters: This function does not accept any parameters. Return value: This function returns the sum of all sequence elements in form of integer or float. Below programs illustrate the Ds\Sequence::sum() function in PHP: Program 1: php <?php // Create new sequence $seq = new \Ds\Vector([5, 7, 8, 14, 23]); // Use sum() function to find // the sum of sequence element var_dump($seq->sum()); ?> Output: int(57) Program 2: php <?php // Create new sequence $seq = new \Ds\Vector([5, 7.5, 8.4, 14, 23]); // Use sum() function to find // the sum of sequence element var_dump($seq->sum()); ?> Output: float(57.9) Reference: http://php.net/manual/en/ds-sequence.sum.php Comment More infoAdvertise with us Next Article PHP | DsSequence reduce() Function V vijay_raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection Similar Reads PHP DsSet sum() Function The Ds\Set::sum() function of Ds\Set class in PHP is an inbuilt function which is used to find the sum of all of the elements present in a Set. Syntax: number public Ds\Set::sum ( void ) Parameter: This function does not accepts any parameter. Return Value: This function returns the sum of the value 1 min read PHP DsMap sum() Function The Ds\Map::sum() function of PHP is used to get the sum of all of the values present in the Map instance. Syntax: number public Ds\Map::sum ( void ) Parameters: This function does not accepts any parameter. Return value: This function returns the sum of all of the values present in the Map instance 1 min read PHP | DsSet reduce() Function The Ds\Set::reduce() function is an inbuilt function in PHP which is used to reduce the set to a single value by applying operations using the callback function. Syntax: mixed public Ds\Set::reduce ( callable $callback [, mixed $initial ] ) Parameters: This function accepts two parameters as mention 2 min read PHP | DsDeque sum() Function The Ds\Deque::sum() function is an inbuilt function in PHP which is used to return the sum of all elements present in the Deque. Syntax: public Ds\Deque::sum( void ) : number Parameters: This function does not accept any parameter. Return Value: This function returns the sum of all Deque elements. B 2 min read PHP | DsVector sum() Function The Ds\Vector::sum() function is an inbuilt function in PHP which returns the sum of all the elements of the vector. Syntax: number public Ds\Vector::sum( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the sum of all elements in the vector. The su 2 min read PHP | DsMap values() Function The Ds\Map::values() function is an inbuilt function in PHP which is used to return a sequence of the map's values. Syntax: Ds\Sequence public Ds\Map::values ( void ) Parameters: This function does not accepts any parameters. Return Value: It returns a Ds\Sequence containing all the values of the ma 1 min read PHP | DsVector reduce() Function The Ds\Vector::reduce() function is an inbuilt function in PHP which reduce the vector to a single value by applying operations in the callback function. Syntax: mixed public Ds\Vector::reduce( $callback, $initial ) Parameters: This function accepts two parameters as mentioned above and described be 2 min read PHP | DsSequence sum() Function The Ds\Sequence::sum() function is an inbuilt function in PHP which is used to return the sum of all values of the sequence. Syntax: number abstract public Ds\Sequence::sum( void ) Parameters: This function does not accept any parameters. Return value: This function returns the sum of all sequence e 1 min read PHP | DsSequence reduce() Function The Ds\Sequence::reduce() function is an inbuilt function in PHP which is used to reduce the sequence to a single value using a callback function. Syntax: mixed abstract public Ds\Sequence::reduce ( callable $callback [, mixed $initial ] ) Parameters: This function accepts two parameters as mentione 2 min read PHP | DsVector slice() Function The Ds\Vector::slice() function is an inbuilt function in PHP which is used to return the sub-vector of the given vector. Syntax: Ds\Vector public Ds\Vector::slice( $index, $length )/pre> Parameters: This function accepts two parameter as mentioned above and described below: $index: This parameter h 2 min read Like