Jump to content

Archived

This topic is now archived and is closed to further replies.

xoluz

Calculate till 2 decimals

Recommended Posts

Hey there!

How can I calculate till 2 decimals after the comma?

I've got something like this now

[code]
$price1 = array_sum($prices);
$test = $price1 * 0.7;
echo $test;
[/code]

Now I'm getting values like 32.233 or 500.300, but they should be 32,23 and 500,30 :s

Share this post


Link to post
Share on other sites
round($value, 2)

look it up in the manual for more info and similar functions.

Share this post


Link to post
Share on other sites
Also, have a look at [a href=\"http://www.php.net/number_format\" target=\"_blank\"]number_format() function[/a]

eg

[code]$test = 32.4567;

echo number_format($test, 2, ',', '');[/code]

--> 32,46

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.