sum

Summary

Returns the sum of all parameters.

Usage

$input_number|sum( value [,...] )

Parameters

NameTypeDescriptionRequired
value number Value to be added to the result. Only if input parameter is omitted.
...

Returns

Number (sum of all parameters + input).

Description

This operator simply adds up all the parameters (including the input parameter, if it is used) and returns the result.

Note: From 3.4 you can no longer send arrays as input value to this operator, the input value and parameters must all be scalar values. Use array_sum instead if you need this functionality.

Examples

Example 1

{sum( 1, 2, 3)}

returns 6.

Example 2

{1|sum( 2, 3, 4)}

returns 10.

Example 3

{let a=1 b=2 c=3}

{$a|sum( $b, $c )}

{/let}

returns 6.

Comments

log in or create a user account to comment.

Contents

Reference

Database diagram
Template operators
    PDF
    Arrays
    Data extraction
    Formatting
    Images
    Logic
    Mathematics
       abs
       ceil
       dec
       div
       floor
       inc
       max
       min
       mod
       mul
       round
       sub
       sum
    Miscellaneous
    Strings
    URLs
    Variables
Template functions
Data fetching
Modules
XML tags


Created

05/02/2004
11:48:42 am
by Balazs Halasy

Last updated

17/02/2004
1:37:24 pm
by Jan Borsodi

Authors

Balazs Halasy
Jan Borsodi



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.