Re: Multiplication of double

From: Date: Sun, 19 Jan 2003 21:01:39 +0000
Subject: Re: Multiplication of double
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-132195@lists.php.net to get a copy of this message
--- Cesar Aracena <icaam@icaam.com.ar> wrote: > I get two numbers from a FORM, one price and one > quantity and I need to make a multiplication with > them in order to store the total amount also as a > double expression... I'm trying with: > > $totalprice = $price * $qty; > > but when I echo the, it gives me just plain old 0 > (zero). Any suggestions? Without seeing more code, it is hard to say, but I imagine $qty and/or $price are not what you think they are. Here is a little example that you might find useful: <? $price = "3.50"; $quantity = 5; $total = $price * $quantity; echo "$total\n"; printf("$%.2f", $total); ?> Chris

« previous php.general (#132195) next »