Hi guys,
I have a number stored in a variable. The number is pulled from the database as 9900..I need to convert this number to 99.00 in order to display to a customer in HTML.
I was wondering how can I achieve this in php.
Thanks.
Hi guys,
I have a number stored in a variable. The number is pulled from the database as 9900..I need to convert this number to 99.00 in order to display to a customer in HTML.
I was wondering how can I achieve this in php.
Thanks.
You can use the number_format() function for that:
echo number_format(9900/100);
$priceInCents = 9900;
$priceInDollars = $priceInCents / 100;
And then you can use round()
or number_format()
as you please.
You can do this by either using money_format or number_format, if you are going to display it as a price you should look at money_format, otherwise, number_format is the way to go.