Good Morning,
I finally made a php calculator program which combines compound interest and added fees, The only problem is when I use the the round() function if the fee ends in a zero it does not show the zero. example </php echo round($var,2);?> if $var equals let's say 3.001 the out put will only be 3, if $var equals 7.3000 the output would be 7.3.
what I would like is the output to be rounded to the next cent example if $var equals 3.001 the the output would be 3.00.
Is their a way to accomplish this? I'm sure I could change all the numerals back a hundreth and then multiply $var by .10, but I think the output would be the same.
Well if anyone has a suggestion I would greatly appreciate it. Thanks

Recommended Answers

All 2 Replies

*Opens new browser window*
*Loads php.net*
*Enters "cents" in the search box, and selects "Online Documentation" from the drop down.*
*Searches*
*Finds link to article about variable precision math*
*Posts link*

Perhaps this would be of some use?
http://www.php.net/manual/en/ref.bc.php

*Opens new browser window*
*Loads php.net*
*Enters "cents" in the search box, and selects "Online Documentation" from the drop down.*
*Searches*
*Finds link to article about variable precision math*
*Posts link*

Perhaps this would be of some use?
http://www.php.net/manual/en/ref.bc.php

*Clicks Link*
*Searches*
*Finds Link http://www.php.net/manual/en/function.bcadd.php*
*Fixes PHP Code*
*Thanks Puckdropper*
thanks appreciate it
*Starts Working On HTML Design for PHP Code*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.