I am processing prices. I need to know how to ensure that my variables all go to the second decimal point (cents).
So how do I convert an integer into a float?
For example I want 15 to be 15.00
Thanks, Corey
I am processing prices. I need to know how to ensure that my variables all go to the second decimal point (cents).
So how do I convert an integer into a float?
For example I want 15 to be 15.00
Thanks, Corey
try number_format()
No, number format is for commas...
I have to side with Mr. K
If you look at the manual page, you'll see that the number_format can be used to do exactly what you are trying to accomplish. You just need to pass in more than one parameter.
No, you're mistaken. Read the text at the link you procided dude, it states quite clearly:
"number_format
(PHP 3, PHP 4 >= 4.0.0)
number_format -- Format a number with grouped thousands"
has nothing to do with converting Integers to floating point numbers which is what I need to do...
Corey
You were right, here it is.
echo number_format($num, 2);
However if you read that link you sent it says nothing about it, I had to search at google until something came up. Thanks.
When I go to the link and read under the Description title, I see:
Description
string number_format ( float number [, int decimals [, string dec_point [, string thousands_sep]]])
And then an explanation of what each parameter does.