Forum Moderators: coopster

Message Too Old, No Replies

new to php - need help with integers

need help with integers

         

amikin

8:30 pm on May 13, 2005 (gmt 0)

10+ Year Member



I'm setting variables for some prices on a site I'm working on. From the variables I then have some functions that calculate tax and totals.

What I want to do is have my end results show the full cost, right now I'm losing and 0's that would appear after the decimal such as $55.00 shows as $55 and $42.20 would come out as $42.2

Is there a way to force the 2 decimals places?

jatar_k

8:43 pm on May 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



welcome to WebmasterWorld amikin,

try this for display
money_format [php.net]
or even
number_format [php.net]

I usually use number_format and just put a $ in front

mcibor

8:51 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may do that with number_format function
<?php
$number = 200;
$english_format_number = number_format($number, 2, '.', '');//answer is 200.00
?>

More at [pl.php.net...]

Best regards
Michal Cibor

amikin

9:10 pm on May 13, 2005 (gmt 0)

10+ Year Member



Perfect!

Thanks for the quick replies.