Reputation: 183
I have a string
like this:
$foo = "1.3223";
How do I convert $foo
into a float
?
Upvotes: 0
Views: 1567
Reputation: 318
Remove the speech marks and PHP should convert into a float. or cast it.
Upvotes: 0
Reputation: 7536
This would do it:
<?php
$var = '122.34343The';
$float_value_of_var = floatval($var);
echo $float_value_of_var; // 122.34343
?>
Upvotes: 1