I got a string like:
$str = "CASH55.35inMyPocket";
I want to get 55.35 only.
I tried:
$str = floatval("CASH55.35inMyPocket");
if ($str > 0) {
echo "Greater_Zero";
} else {
echo "LessZERO!!";
}
// echo "LessZERO!!";
I also tried:
$str = (float)"CASH55.35inMyPocket";
if ($str > 0) {
echo "Greater_Zero";
} else {
echo "LessZERO!!";
}
// echo "LessZERO!!";
According to the Documentation:
Strings will most likely return
0
although this depends on the leftmost characters of the string.
So, flotval
and (float)
apparently only work if the string is something like:
55.35aAbBcCdDeEfF
... but will NOT work if it is like: aAbBcC55.35dDeEfF
is there a way to get the float no matter the position of text?