PHP Ds\Set sum() Function Last Updated : 16 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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 values present in a Set. The return type of the function can be integer or float depending on the type of values present in the Set instance. Below programs illustrate the Ds\Set::sum() function: Program 1: php <?php // Declare an empty set $set = new \Ds\Set([1, 2, 3, 4, 5]); // Print the sum of all values echo("Sum of all values is: "); print_r($set->sum()); ?> Output: Sum of all values is: 15 Program 2: php <?php // Declare an empty set $set = new \Ds\Set([1.1, 2.2, 3.5, 4.9, 5]); // Print the sum of all values echo("Sum of all values is: "); print_r($set->sum()); ?> Output: Sum of all values is: 16.7 Reference: http://php.net/manual/en/ds-set.sum.php Comment More infoAdvertise with us Next Article PHP DsMap sum() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set 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 | 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 | unset() Function In PHP, the unset() function is used to destroy a variable, array element, or object. Once a variable or array element is "unset", it is completely removed from memory, and it no longer exists in the program. This function is essential for freeing up memory by removing unwanted or unnecessary data d 3 min read PHP array_sum() Function The array_sum() function in PHP is used to calculate the sum of values in an array. It works with both indexed and associative arrays and can handle arrays containing both integers and floats. If the array is empty, it returns 0.number array_sum ( $array )Syntaxnumber array_sum(array $array)Paramete 2 min read Like