Adding a zero after computation
Hi Everyone I've come across a little problem
I've been working on a simple shopping cart
and so far so good but after computing the
totals they do not appear as floats with 2 decimal
places (£2.50 is £2.5)..how can i avoid this problem.
Please help
Here's my code:
Code:
$total2=$light_packages * $price2 * $years_light;
Re: Adding a zero after computation
add this after that line:
PHP Code:
$total2 = number_format($total2, 2);
EDIT:
you may also want to look at this http://us3.php.net/manual/en/function.money-format.php
Re: Adding a zero after computation
thankyou that worked fine ...thanks for the info too :wave:
Re: Adding a zero after computation
your welcome :)
please set this post as resolved, and give reputation accordingly :)