Re: newbie question
| From: | Eugene Lee | Date: | Sun, 12 Oct 2003 10:30:49 +0000 |
| Subject: | Re: newbie question | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165890@lists.php.net to get a copy of this message | ||
On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote:
:
: If I get rid of the 0 and tried this:
:
: $price=.65;
: $f_price=sprintf("%1.2f",$price);
:
: It displays "0.65" in my Mozilla browser correctly. What do you say then?
I say, "I dunno". :-) It seems to follow C's printf(3) conversion
specification. If a decimal point is needed for a float, it must also
have a digit in front of the decimal point. This is kind of annoying if
I want to print decimal-only values without preceding zeroes. Maybe
money_format() is a better solution.
: BTW, what's the 1 used for?
Specifies the minimum character width of the conversion. See PHP's
sprintf() docs for more details.