I got a line like:
$str = "CASH55.35inMyPocket";
I want to get only 55.35 .
I did my best:
$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:
Lines are likely to return 0 although this depends on the leftmost characters of the line.
So flotval and (float) obviously only work if the line looks like: 55.35aAbBcCdDeEfF ... but will NOT work if it looks like: aAbBcC55.35dDeEfF
Is there any way to get swimming regardless of the position of the text?
string php
Universal grasp
source share