Problem in displaying number format with comma and two decimal places
I use round syntax in displaying my computation and the result is correct. but it has no comma.
Like for example the result is 3020, I want it to 3,020.00
I have this syntax:
$Amount = round(($Hours/8)* $Rate, 2);
but when I tried number_format it displayed correct but I think the data or the amount is wrong because I sum amount in other earnings before i change the format, the output is 5524.28, but when I change my format of my amount the sum of other earnings and amount become 2507.88, so the data that get in amount is only 3.6.
i only want is adding comma, with changing the real amount or data.
There is no reason I know of that you can't use number_format(). But any function you use that puts in thousands separators will create a string representation of a number. If you try to then use it as a number using PHP mathematical operators, it will cast that string to a numerical type, at which point things will go wrong. E.g. "123,456.78" would be cast to 123. The "trick" is to only use number format when you actually output something: