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: Chandan Kumar

Recent Posts

Categories

Tags

Leave a Reply

Your email address will not be published. Required fields are marked *