RE: [PHP] showing the decimal places
| From: | Rob Agar | Date: | Thu, 17 Mar 2005 06:09:53 +0000 |
| Subject: | RE: [PHP] showing the decimal places | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-210938@lists.php.net to get a copy of this message | ||
> From: ross@aztechost.com [mailto:ross@aztechost.com]
> when I define a number as
>
> $number = 2.00
>
> then echo it the number shows as 2. How can I get the two
> zeros to show?
>
> This is not in any of my books but a fairly easy solution I'll bet!
the function you want is called sprintf (s for string, f for format)
summat like this:
echo sprintf('%0.2f', $number);
hth,
Rob Agar