PHPackages                             mvccore/ext-tool-locale-floatparser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. mvccore/ext-tool-locale-floatparser

ActiveLibrary[Framework](/categories/framework)

mvccore/ext-tool-locale-floatparser
===================================

MvcCore - Extension - Tool - Locale - FloatParser - parse float by automatic floating point detection or parse float value by `Intl` extension.

v5.3.0(1y ago)11.3k11BSD-3-ClausePHPPHP &gt;=5.4.0

Since Jan 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mvccore/ext-tool-locale-floatparser)[ Packagist](https://packagist.org/packages/mvccore/ext-tool-locale-floatparser)[ RSS](/packages/mvccore-ext-tool-locale-floatparser/feed)WikiDiscussions master Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (1)

MvcCore - Extension - Tool - Locale - FloatParser
=================================================

[](#mvccore---extension---tool---locale---floatparser)

Parse float by automatic floating point detection or parse float value by `Intl` extension.

[![Latest Stable Version](https://camo.githubusercontent.com/6a0e9e7da98c52006afe617f10a93df0da2dce64b73eedf5b9b3fcee6bfb6039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f537461626c652d76352e332e302d627269676874677265656e2e7376673f7374796c653d706c6173746963)](https://github.com/mvccore/ext-tool-locale-floatparser/releases)[![License](https://camo.githubusercontent.com/53baed538c1c87a033a212f6f4acce684d36137f8622307643ab25e08118452e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d425344253230332d627269676874677265656e2e7376673f7374796c653d706c6173746963)](https://mvccore.github.io/docs/mvccore/5.0.0/LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/9e923690739211296a00adce5d359999dfa345f80fc1b2e2cfe72c49523ee334/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d352e342d627269676874677265656e2e7376673f7374796c653d706c6173746963)](https://camo.githubusercontent.com/9e923690739211296a00adce5d359999dfa345f80fc1b2e2cfe72c49523ee334/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d352e342d627269676874677265656e2e7376673f7374796c653d706c6173746963)

Installation
------------

[](#installation)

```
composer require mvccore/ext-tool-locale-floatparser
```

Usage
-----

[](#usage)

### Non `Intl` Automatic Floating Point Detection

[](#non-intl-automatic-floating-point-detection)

Non `Intl` parsing with automatic floating point detection has better results for unexpected user inputs like: `'1.2 3'			=> 1.23			(float)``'1.2 3 and 4'		=> 1.234		(float)``'-1,234,567.89'	=> -1234567.89	(float)``'-1.234.567,89'	=> -1234567.89	(float)``'-1 234 567.89'	=> -1234567.89	(float)``'-1 234 567,89'	=> -1234567.89	(float)`

#### Example

[](#example)

```
$autoParser = \MvcCore\Ext\Tools\Locales\FloatParser::CreateInstance(
	'en',	// international language code, lowercase
	'US', 	// international country code, uppercase
	FALSE	// FALSE (by default) to prefer automatic floating point detection
);
var_dump($autoParser->Parse('-1,234,567.89'));	// -1234567.89	(float)
var_dump($autoParser->Parse('-1.234.567,89'));	// -1234567.89	(float)
var_dump($autoParser->Parse('-1 234 567.89'));	// -1234567.89	(float)
var_dump($autoParser->Parse('-1 234 567,89'));	// -1234567.89	(float)
var_dump($autoParser->Parse('1.2 3 and 4'));	// 1.234		(float)
var_dump($autoParser->Parse('1.2 3'));			// 1.23			(float)
// rest is the same as `Intl` floating point parser bellow:
var_dump($autoParser->Parse('1.8e308'));		// INF			(float)
var_dump($autoParser->Parse('1.79e308'));		// 1.79E+308	(float)
var_dump($autoParser->Parse('21474836470'));	// 21474836470	(float)
var_dump($autoParser->Parse('123'));			// 123.0		(float)
var_dump($autoParser->Parse('-3.14'));			// -3.14		(float)
var_dump($autoParser->Parse('1.2e3'));			// 1200			(float)
var_dump($autoParser->Parse('7E-10'));			// 7.0E-10		(float)
var_dump($autoParser->Parse('bob-1.3e3'));		// -1300		(float)
var_dump($autoParser->Parse('nothing'));		// NULL
var_dump($autoParser->Parse(TRUE));				// NULL
var_dump($autoParser->Parse([]));				// NULL
var_dump($autoParser->Parse(new \stdClass));	// NULL
```

### `Intl` Parsing

[](#intl-parsing)

`Intl` parser needs to set up language and locale more precisely to user input expectations, which is more error prone in very foreing languages and their locale conventions.

Mostly all languages use floating point character `.` or `,`, but `Intl`library has sometimes not the same values for floating point char in specific locale as operation system has for specific locale, there is a little mess. That's why sometimes there is better to use non `Intl`floating point parsing.

#### Example

[](#example-1)

```
$intlParser = \MvcCore\Ext\Tools\Locales\FloatParser::CreateInstance(
	'en',	// international language code, lowercase
	'US', 	// international country code, uppercase
	TRUE	// TRUE to prefer `Intl` extension parsing
);
var_dump($intlParser->Parse('-1,234,567.89'));	// -1234567.89	(float)
var_dump($intlParser->Parse('-1 234 567,89'));	// -1234567		(float)
var_dump($intlParser->Parse('-1 234 567.89'));	// -1234567.89	(float)
var_dump($intlParser->Parse('-1 234 567,89'));	// -1234567		(float)
var_dump($intlParser->Parse('1.2 3 and 4'));	// 1.2			(float)
var_dump($intlParser->Parse('1.2 3'));			// 1.2			(float)
// rest is the same as non `Intl` floating point parser above:
var_dump($autoParser->Parse('1.8e308'));		// INF			(float)
var_dump($autoParser->Parse('1.79e308'));		// 1.79E+308	(float)
var_dump($autoParser->Parse('21474836470'));	// 21474836470	(float)
var_dump($intlParser->Parse('123'));			// 123.0		(float)
var_dump($intlParser->Parse('-3.14'));			// -3.14		(float)
var_dump($intlParser->Parse('1.2e3'));			// 1200			(float)
var_dump($intlParser->Parse('7E-10'));			// 7.0E-10		(float)
var_dump($intlParser->Parse('bob-1.3e3'));		// -1300		(float)
var_dump($intlParser->Parse('nothing'));		// NULL
var_dump($intlParser->Parse(TRUE));				// NULL
var_dump($intlParser->Parse([]));				// NULL
var_dump($intlParser->Parse(new \stdClass));	// NULL
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~467 days

Total

4

Last Release

534d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a68d9cd696ed584a9ee742fa089d0650f4f7a95754bf5d9ee301e6c9013df3fd?d=identicon)[tomFlidr](/maintainers/tomFlidr)

---

Top Contributors

[![tomFlidr](https://avatars.githubusercontent.com/u/1833722?v=4)](https://github.com/tomFlidr "tomFlidr (26 commits)")

---

Tags

pluginframeworklocalizationinternationalizationlanguagestoolmvcextensionplug-inlocalesextsetlocalemvccoreteritories

### Embed Badge

![Health badge](/badges/mvccore-ext-tool-locale-floatparser/health.svg)

```
[![Health](https://phpackages.com/badges/mvccore-ext-tool-locale-floatparser/health.svg)](https://phpackages.com/packages/mvccore-ext-tool-locale-floatparser)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
