I have $number = '345,6';
and $time = '1';
After $sum = $number * $sum;
the $sum
becomes 345
, instead of 345,6
Why is that and how to prevent losing comma and numbers ?
First of all, don't store numbers as strings. Secondly, use a dot to separate the fractional part. Like this:
$number = 345.6;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments