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).
Package info
github.com/konstantind/otus-flexible-float-parser
pkg:composer/konstantind/otus-flexible-float-parser
Requires
- php: >=7.0.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-08-30 14:14:03 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