Page 1 of 1
how to convert string to number for calculations...
Posted: Thu Nov 17, 2011 1:47 pm
by grabber_grabbs
I have $qty and $amount that are both strings. i would like to do $qty * $amount.
I have tried intval($qty) * intval(amount) but i loose the decimal if i do it that way... 4 * 8.29 = 32
1.75 * 2.00 = 3.50 < this is what i want.
thanks.
Re: how to convert string to number for calculations...
Posted: Thu Nov 17, 2011 1:50 pm
by Celauran
Re: how to convert string to number for calculations...
Posted: Thu Nov 17, 2011 4:05 pm
by grabber_grabbs
Thanks Celauran again, do you know why this is not working ?
$extvalue = floatval($QUANTITY_0) * floatval($PRICE_0);
$extvalue = sprintf("%8,2", $extvalue);
echo $extvalue
// if qty = 1 and price = 1.50 i still have 1.5 after the springf function applied. I would like to have 1.50 for the result.
// floatval is doing what it should.
Re: how to convert string to number for calculations...
Posted: Thu Nov 17, 2011 4:17 pm
by Celauran