On Thursday 03 May 2001 08:53, Jennifer wrote:

> I have a shopping cart that allows decimal points for quantities.
> I like it like that, but would like to remove any trailing zeros
> and if the quantity is not a fraction I would like to remove the
> decimal point too.
>
> What would be the easiest way to do this?  I don't see any
> function that would make it easy.

It's so easy that you don't need a function for it :)

$Qty = "12.470";
$Qty_real = (double) $Qty;

echo "$Qty - $Qty_real";

In other words - convert it from a strin to a floating-point number and 
PHP will do the rest.

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

Drink wet cement. Get stoned.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to