|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mrekers Smarty n00b
Joined: 30 Dec 2013 Posts: 2
|
Posted: Mon Dec 30, 2013 2:40 pm Post subject: count values of fields in an array |
|
|
I would like to sum up all the values of one column within the array shown below. Field one contains a date, field two a name, field five a number, and I would like them all to be counted together, but somehow I can't get this done.
---------------
{foreach from=$list item=entry}
{$entry->fields[1]}
{$entry->fields[2]}
{$entry->fields[5]|number_format:2:",":"."}
{/foreach}}
{sum of all $entry->fields[5]}
Help is appreciated
Thanx! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Dec 31, 2013 8:04 pm Post subject: |
|
|
For Smarty3
Code: |
{$sum = 0}
{foreach from=$list item=entry}
{$entry->fields[1]}
{$entry->fields[2]}
{$entry->fields[5]|number_format:2:",":"."}
{$sum = $sum + $entry->fields[5]}
{/foreach}
{$sum}
|
|
|
Back to top |
|
mrekers Smarty n00b
Joined: 30 Dec 2013 Posts: 2
|
Posted: Wed Jan 01, 2014 9:33 am Post subject: |
|
|
Goodmorning, Thank you very very much!
(sometimes things can be so simple, you break your head looking for difficult solutions....)
Thanx |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|