Skip to content

drrcknlsn/number-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NumberConverter

NumberConverter is a simple interface for converting numbers from their numeric representations into their written, lingual representations. Other, probably better solutions already exist (see below), and this was created only as a coding exercise.

Example

$converter = new DrrckNlsn\NumberConverter\EnglishNumberConverter();
echo $converter->convert(1234567);

Output:

one million two hundred thirty four thousand five hundred sixty seven

Internationalization

Currently, there is only an EnglishNumberConverter implementation, but the project was created with other languages in mind.

Demo

This package comes with a simple CLI binary for demonstrating the EnglishNumberConverter class, located at bin/convertNumber.

Installing via Composer

The recommended way to install NumberConverter is via Composer:

composer require drrcknlsn/number-converter

After installing the dependency, you will need to require Composer's autoloader:

require 'vendor/autoload.php';

Existing Solutions

The intl extension provides the NumberFormatter class, which can be used to accomplish the same goal, using NumberFormatter::SPELLOUT.

About

NumberConverter is a tool to convert numbers to their written, lingual form.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages