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

Chandan Kumar doesn't just write code; he builds digital legacies. As the Founder and Team Lead at AvyaTech, Chandan combines high-level strategy with granular technical expertise to turn "what if" into "it's live." When he’s not steering his team through complex development sprints, he’s busy architecting the future of scalable, user-first technology.

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