I have "0.05" as a string in php. How can I turn it into a number with intval()?
Wenn I try this
intval("0.05")
it just gives
0
How can I solve this?
I have "0.05" as a string in php. How can I turn it into a number with intval()?
Wenn I try this
intval("0.05")
it just gives
0
How can I solve this?
Type cast it as a float
$x = "0.05";
$y = (float)$x;
var_dump($y); // float(0.05)
Note that this may require some finessing as floats are notoriously imprecise
You are using int-val. This will give you an integer answer. Since you are working with a decimal fraction, what you need is floatval
.
floatval("0.05");