array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'es', ), 'this' => array ( 0 => 'ds-map.sum.php', 1 => 'Ds\\Map::sum', ), 'up' => array ( 0 => 'class.ds-map.php', 1 => 'Ds\\Map', ), 'prev' => array ( 0 => 'ds-map.sorted.php', 1 => 'Ds\\Map::sorted', ), 'next' => array ( 0 => 'ds-map.toarray.php', 1 => 'Ds\\Map::toArray', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ds/ds/map/sum.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(No version information available, might only be in Git)
Ds\Map::sum — Returns the sum of all values in the map
Returns the sum of all values in the map.
Nota:
Arrays and objects are considered equal to zero when calculating the sum.
Esta función no tiene parámetros.
The sum of all the values in the map as either a float or int depending on the values in the map.
Ejemplo #1 Ds\Map::sum() integer example
<?php
$map = new \Ds\Map(["a" => 1, "b" => 2, "c" => 3]);
var_dump($map->sum());
?>
El resultado del ejemplo sería algo similar a:
int(6)
Ejemplo #2 Ds\Map::sum() float example
<?php
$map = new \Ds\Map(["a" => 1, "b" => 2.5, "c" => 3]);
var_dump($map->sum());
?>
El resultado del ejemplo sería algo similar a:
float(6.5)