Re: Is It Possible to Tell PHP To Output x Decimal Places Per Float?

From: Date: Mon, 09 Jun 2003 22:46:23 +0000
Subject: Re: Is It Possible to Tell PHP To Output x Decimal Places Per Float?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-150824@lists.php.net to get a copy of this message
On Mon, 2003-06-09 at 15:22, Dan Anderson wrote: > Is it possible to tell PHP when converting a number to a string (i.e. in > an echo or print command) to use x decimal places? > > Specifically, if I > > <?php > echo '$' . $some_price; > ?> > > And some_price is $1.50, it outputs: > > $1.5 > > Thanks in advance, > > Dan http://ca2.php.net/manual/en/function.number-format.php ...i.e.: <?php error_reporting(E_ALL); $someValue = 1.50; echo '$' . number_format($someValue, 2) . "\n" ?> Hope this helps, Torben -- Torben Wilson <torben@php.net> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----

« previous php.general (#150824) next »