php sum zero value to float number

476 views Asked by At

I'm in trouble with this:

$price = 26,20;
$increase = 0,00;
$decrease = 0,00;

$result = ($price + $increase - $decrease);  

Result becomes 26 instead of 26,20

Any idea?

Thnx!

1

There are 1 answers

0
kamal pal On BEST ANSWER

You can use number_format in case you need comma as decimal separator, see example below:

$price = 26.20;
$increase = 0.00;
$decrease = 0.00;

$result = ($price + $increase - $decrease);
echo number_format($result , 2, ',', '');