parse decimal number from string


$string = "$4.9/inch";
$res = filter_var($string, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
echo $res;

It will print
4.9

Author: admin

Leave a Reply

Your email address will not be published.