I need to transform a String to a Float.
I will receive Strings like this:
$string = "1.70 m";
$string2 = "2.445 m";
How can I easly transform this strings to:
$float1 = 1.70;
$float2 = 2.445;
Can someone give me some clues?
Best Regards,
I need to transform a String to a Float.
I will receive Strings like this:
$string = "1.70 m";
$string2 = "2.445 m";
How can I easly transform this strings to:
$float1 = 1.70;
$float2 = 2.445;
Can someone give me some clues?
Best Regards,
The easiest way to do this is probably with the floatval() function:
http://ca.php.net/manual/en/function.floatval.php
For exmaple:
floatval("1.70 m");
gives you:
1.7