Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Addition value in foreach cycle

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
ueilmaster
Smarty n00b


Joined: 24 Jul 2020
Posts: 1

PostPosted: Fri Jul 24, 2020 2:36 pm    Post subject: Addition value in foreach cycle Reply with quote

I need to get a total of values in every iteration of a foreach

for example

I've got Width value, for every iteration need a total of width's value to use in a math equation

{foreach from=$data_table item=curr name="ciclone"}

{math equation='(x+y)+(g*z)' x='100' y='1400' g='50' z="{$smarty.foreach.ciclone.iteration}"}

{/foreach}

z is the current iteration,
g and x are variables get from array,
Y= the amount of total width dawn current iteration;
{$curr.Width} is each value in the array $data_table, not the same for every iteration,

I need something like examples:

$total_width till 1 dawn {$smarty.foreach.ciclone.iteration}
500 = 500 + (till 1 dawn 1)
800 = 500+300 (till 1 dawn 2)
1500 = 500+300+700 (till 1 dawn 3) ...

hope I have been clear

thanks in advance
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP