How do I multiply a price in PHP and keep the zeroes at the end?
I'm building a simple e-commerse site in php. In the cart where the product prices are added, I simply multiply them ie. $totalPrice=$price * $qty, but, any zero's at the end get chopped off. It's ok if the total price of items is, say.. $10.52, but any zero's don't display after they've been muliplied.
Here is the url to my site www.allthingsskin.com.au
If you add an ite开发者_如何学JAVAm to the cart you'll see what I'm trying to explain.
Any help is GREATLY appreciated.
Thanks
Mark
number_format is the function you are looking for. The first parameter is your total, the 2nd parameter is the number of decimal places.
echo number_format(10, 2); // returns 10.00
You can also use money_format.
精彩评论