I have this code:
for($i = 1; $i <= $max; $i+=0.1) {
echo "$i<br>";
}
if the variable $max = 6; the results are: 1, 1.1, 1.2, 1.3 .... 5.8, 5.9, 6 , but when the variable $max = 4 the results are: 1, 1.1 ... 3.8, 3.9, but the number 4 is missing.
Please explain this behavior, and a possible solution to this.
the results are the same when i use the condition $i <= $max; or $i < $max;
The bug occurs when $max is 2, 3 or 4