PHP

PHP: How To Parse Decimal Number from String

Author By Chandan Kumar
May 1, 2020
8 min read
Share:
PHP How To 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

Chandan Kumar

Chandan Kumar

Related Articles

Continue reading with these hand-picked articles on similar topics.

How to Create Social login in CakePHP With HybridAuth Library
PHP
How to Create Social login in CakePHP With HybridAuth Library
Today I am writing about new steps that how to create a social login in CakePHP with HybridAuth library.
Chandan Kumar July 21, 2017