문제

This is my code:

$subTotal = number_format($subTotal, 2);

In $subTotal I had a value like 1,233.00 as a string. The return value was 1.00, which of course is wrong. So I tried something else:

$subTotal = number_format($subTotal, 2, '.', ',');

Result is still the same. How can I make it work with a , as thousand separator?

Thanks!

도움이 되었습니까?

해결책

Remove the commas before you call number_format()

$subTotal = number_format(str_replace(',', '', $subTotal), 2);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top