|Ratings|| ||Unique User Downloads|| ||Download Rankings|
|Not yet rated by the users||Total: 69 ||All time: 10,037 This week: 289|
This package can convert a string with amount in words to a number.
It can take a text string that has words that express a given amount and parses it to extract the number that it represents.
The package can potentially support processing number strings in multiple languages. Currently it supports converting strings to numbers in English.
Word To Number
This PHP package allows you convert numbers written in words to integers
You can install the package via composer:
composer require djunehor/word-to-number
$wordToNumber = new WordToNumber();
$wordTransformer = $wordToNumber->getWordTransformer();
// you can specify locale via: $wordToNumber->getWordTransformer('en');
$number = $wordTransformer->toNumber($word);
$number = word_to_number($word);
//default locale is en
$number = word_to_number($word, 'yo');
// specify Yoruba locale
|:--------- | :-----------------: | :------: |
Adding New Locale
In `Locales` directory, create `YourLocaleTransformer` class that implements `WordTransformer`
Ensure there's a `toNumber()` method that accepts string and returns int
Add `YourLocaleTransformer::class` to `$wordTransformers` array in `WordToNumber`
Ensure the class pass tests
Update the Readme Available Locales section with your newly added locale
Create a Pull Request
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.