RE: [PHP] Is It Possible to Tell PHP To Output x Decimal Places Per Float?
| From: | John W. Holmes | Date: | Mon, 09 Jun 2003 22:48:34 +0000 |
| Subject: | RE: [PHP] 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-150822@lists.php.net to get a copy of this message | ||
> 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?
Yes, it is.
> Specifically, if I
>
> <?php
> echo '$' . $some_price;
> ?>
>
> And some_price is $1.50, it outputs:
>
> $1.5
>
> Thanks in advance,
You're welcome.
---John W. Holmes...
Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
PS: Look at the printf() or sprintf() function. And don't ask YES/NO
questions. :)