Jan 21, 2003 #1 Laugher Technical User Oct 9, 2002 4 AU Is there a simple way to round numbers in php? I am trying to build a currency calculator and would like the output to two decimal places. Thanks in advance.
Is there a simple way to round numbers in php? I am trying to build a currency calculator and would like the output to two decimal places. Thanks in advance.
Jan 21, 2003 #2 danielhozac Programmer Aug 21, 2001 2,058 SE Code: sprintf("%.2f", $variable); //Daniel Upvote 0 Downvote
Jan 21, 2003 #3 sleipnir214 Programmer May 6, 2002 15,350 US Another function to explore (though danielhozac's suggestion will work well) is number_format() (http://www.php.net/manual/en/function.number-format.php). Want the best answers? Ask the best questions: http://www.tuxedo.org/~esr/faqs/smart-questions.htmlTANSTAAFL! Upvote 0 Downvote
Another function to explore (though danielhozac's suggestion will work well) is number_format() (http://www.php.net/manual/en/function.number-format.php). Want the best answers? Ask the best questions: http://www.tuxedo.org/~esr/faqs/smart-questions.htmlTANSTAAFL!
Jan 21, 2003 Thread starter #4 Laugher Technical User Oct 9, 2002 4 AU Thank you for you help. Upvote 0 Downvote
Jan 23, 2003 #5 Lynux MIS Aug 3, 2001 33 US Also // round 2 dec. points round($variable,2) ================================= Imagination is more important than knowledge. (A.E.) Upvote 0 Downvote
Also // round 2 dec. points round($variable,2) ================================= Imagination is more important than knowledge. (A.E.)