Question

I have a small problem. i have got an amount that has multiple numbers after the comma.

The amount is 89,3500205 and when i use the number_format or an other format function it changes the amount to 89,00 instead of 89,35.

I am doing

<?= echo number_format($var, 2); ?>

Does anyone has an suggestion for this problem?

Thx

Était-ce utile?

La solution

Are you sure you're not getting a A non well formed numeric value encountered error? Is your error_reporting on?

Try replacing , to .

echo number_format(str_replace(",",".",$var),2);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top