Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Decipher a code 31.12.2012 03:29

I'm trying to understand this code I grad from your "Estimate business card" example. Can you please explain this?:

for ($i = 1; $i

Re: Decipher a code 31.12.2012 09:41



for ($i = 1; $i


Hello,

This is a conditional statement mostly used to go through an array(list) of elements. In calcbuilder you can use it to get elements with more than one value from form. For example, if you use a "multiple option" field with "var" name 'multiple' , you can see in form checkboxes to select. You can use 'multiple' values in 'code' as array. To get all values separated with commas you could use 'for' structure like this:

$multiple_values='';
for($i=0;$i' is to apply number format to them

for ($i = 1; $i r$i"."1,2);");
}


First we declare for only for 5 elements, because it´s the number of vars we have.

for ($i = 1; $i te '$var' as string with $i from the loop and '1', so in first step the result will be $var11, in next step $var21 and so on. This variable (the same we declare before loop) is assigned to the result of number format function.

eval("\$var$i"."1=number_format(\$var$i"."1,2);");


This 'for' statement is the shortcut for doing this:
$var11=number_format($var11,2);
$var12=number_format($var12,2);
$var13=number_format($var13,2);
$var14=number_format($var14,2);
$var15=number_format($var15,2);


Hope this helps. Regards,

Editado por MSTeam - 31.12.2012 09:43
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback