CalcBuilder Forum

MULTIPLY FUNCTION

Usuario moon_912 2013-02-12 15:51:56

Could you please tell how can I multiply option list value with linked list value.
if option list value is 5 and linked list is 5_10, so logically, the formula must contain 5x10, but unfortunately I can't get to this line.

$result=$option*$option_linked (but the result is 5*5, not 5*10)

so, the question is how correctly write a formula to get the multiplation 5*10

Moonsoft support 2013-02-12 16:38:07

Hello,
yes, when you recover the value of the $option_linked, you get the whole value

(5_10)

In order to use the values inside a formula, you should previously 'split' that value in two pieces, and use the second part to build your math. This is the code needed:

$myvalue=explode("_",$option_linked);

//Now you have at 'myvalue' the two separate parts.
// $myvalue contains the first part
//$myvalue contains the second part

//So you can use

$result=$option*$myvalue;

//to multiply 5*10

Hope this helps, regards

Usuario moon_912 2013-02-12 17:19:49

Thank you

...
CalcBuilder

Create dynamic calculators

Buy now!
...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!