Re: Trailing zeros in floats
| From: | Salman AS | Date: | Fri, 07 Jul 2000 10:26:03 +0000 |
| Subject: | Re: Trailing zeros in floats | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5358@lists.php.net to get a copy of this message | ||
Niklas Brunlid wrote:
> Probably a very simple question, but:
> How do I get a floating point number to be displayed as 2.5 instead of
> 2.5000?
Use printf() or sprintf() to format it. follow this script,
<?php
$a=2.5;
printf("%3.1f", $a);
printf("%3.4f", $a);
?>
Just see the manual!
Cheers,
SaS