문제

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

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top