konstantind / otus-flexible-float-parser
Flexible Float Parser is a lightweight PHP package that converts numeric strings with either a comma or a dot as a decimal separator into a float. It supports negative numbers and values without a leading zero (e.g., .5 → 0.5).
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/konstantind/otus-flexible-float-parser
Requires
- php: >=7.0.0
This package is not auto-updated.
Last update: 2025-12-21 10:31:54 UTC
README
Flexible Float Parser is a lightweight PHP package that converts numeric strings with either a comma or a dot as a decimal separator into a float. It supports negative numbers and values without a leading zero (e.g., .5 → 0.5).
Installation
composer require konstantind/otus-flexible-float-parser
Use
<?php
$floatValue = FlexibleFloatParser::parse('3,14'); // 3.14
$floatValue = FlexibleFloatParser::parse('.5'); // 0.5
$floatValue = FlexibleFloatParser::parse(''); // null
$floatValue = FlexibleFloatParser::parse('abc'); // null