PHP Ds\Map sum() Function Last Updated : 21 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. The return type of the function can be int or float depending on the type of value present in the Map. Below programs illustrate the Ds\Map::sum() function: Program 1: php <?php // PHP program to illustrate sum() function $map = new \Ds\Map([1 => 10, 2 => 20, 3 => 30]); // The function returns an int which is // the sum of values present in the Map print_r($map->sum()); ?> Output: 60 Program 2: php <?php // PHP program to illustrate sum() function $map = new \Ds\Map([1 => 10, 2 => 20.9, 3 => 30]); // The function returns a float value which is // the sum of values present in the Map print_r($map->sum()); ?> Output: 60.9 Reference: http://php.net/manual/en/ds-map.sum.php Comment More infoAdvertise with us Next Article PHP DsSet sum() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_map Similar Reads 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 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 | 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 | DsDeque map() Function The Ds\Deque::map() function is an inbuilt function in PHP which is used to return the Deque with each element modified on the basis of operation performed as per the callback function. Syntax: public Ds\Deque::map( $callback ) : Ds\Deque Parameters: This function accepts single parameter $callback 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 | DsVector map() Function The Ds\Vector::map() function is an inbuilt function in PHP which is used to return the result of a callback after applying to each value in the vector. Syntax: Ds\Vector public Ds\Vector::map( $callback ) Parameters: This function accepts single parameter $callback which is to be applied to each ve 2 min read Like