Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Addition value in foreach cycle

 
Post new topic   Reply to topic    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:   
Post new topic   Reply to topic    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